473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to use putty code for telnet server

5
I want use putty code for writing a C program in linux.
My program is a small telnet server that user log into it and send command to server.
How can I use putty source code? What files is needed?
May 27 '10 #1
8 6961
Banfa
9,065 Expert Mod 8TB
Given that putty is an ssh client I can see it being any help in writing telnet server.

However the telnet protocol is a fairly simple one. It is transmitted over a simple tcp socket and uses 7bit ascii data for carrying text commands with control data flagged by have bit 7 in the data set.

It isn't to hard to build a basic telnet server (one that refuses all options) have a read about it on Wikipedia http://en.wikipedia.org/wiki/Telnet and don't forget to read the external links.
May 27 '10 #2
omidrh
5
I have written the telnet server, my problem is i can't send commands to the client using the send and write function,
For example i want to send "IAC Dont Echo" to the client but this is displayed like any text message and isn't interpreted as a command.
I wanted to use putty for this, could you help me?
Thanks.
May 27 '10 #3
Banfa
9,065 Expert Mod 8TB
"IAC Dont Echo" should not be sent as text because then it will just be interpreted as text for the telnet client.

It should be sent as the string of bytes

0xFF 0xFE 0X01

Follow the link I posted and read the page and then follow the external links and read those pages too.
May 27 '10 #4
omidrh
5
thanks Banfa for reply but i still have problem

This is my c++ code for turn off echo but it doesnt work. Whats the problem?

Expand|Select|Wrap|Line Numbers
  1. #define IAC 255
  2. #define DONT 254
  3. #define ECHO 1
  4.  
  5. ...
  6.  
  7. char test[256];
  8. bzero(test, 256);
  9.  
  10. sprintf(test, "%c%c%c\n", IAC, DONT, ECHO);
  11. int n = write(sockfd, test, strlen(test));
  12.  
  13. n = recv(sockfd, test, 256, 0);
  14.  
May 28 '10 #5
omidrh
5
the dont echo problem is solved. the code was right, the problem was i was testing from localhost.
Now the problem is I cant turn echo on. I write the same code with DO ECHO but it doesnt work. whats the problem now?
May 28 '10 #6
Banfa
9,065 Expert Mod 8TB
You need to check the reply from the server, it may have replied with a WONT in which case echo wont be on.

All transmitted control codes have a handshake (a reply) you should be checking for codes sent by the server in the first place and handshaking them.

You shouldn't really treat your array of control characters as a string because it will go wrong if you ever need to transmit a 0.
May 28 '10 #7
omidrh
5
How can i check the reply from the server? can you show me a sample code because I'm a beginner and not very familiar with these thing. All the things I read just explain about echo, not how to write the code to enable or disable it.
May 28 '10 #8
Banfa
9,065 Expert Mod 8TB
When you read data from the server using recv you should being checking that data to see if any of it is control codes.

Just check the value of the bytes, you can look for 255 since all control codes are prefixed with a 255 byte.
May 28 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: G520 | last post by:
Hi I have been getting statistical rapports from a machine via a telnet server. Until now it has been done manually. However I want to automate the proccess, and scedule a PHP script to run...
1
by: kumar | last post by:
Hi all, I want to write a telnet server for an embedded linux box using python.The problem is that it doesn't give a shell ( just a limited CLI commands for configuring it . )My requirement is...
5
by: Jim Isaacson | last post by:
Hi I'm looking for some help or a sample of a socket call to talk to a telnet server and send a telnet break from a C program. I've looked at the Stevens book and tried examples of his daytime...
3
by: Steve Koon | last post by:
Anyone know of a C# telnet server code that I can look at. I want to integrate a telnet server function inside a application that I am writing. Thanks,
3
by: Benny | last post by:
I have been looking into developing a MUD in C# and most of the help out there is for C++. I would prefer C# so I was hoping someone could point me in the right direction. I just need a jump...
2
by: dakman | last post by:
I have been working on a project for some time now, that has various types of admistrating including a CGI web interface, In a previous version I implemented a Psuedo-Telnet Server if you will,...
2
Bhanu Murthy
by: Bhanu Murthy | last post by:
I have Win2000 Server having 30 clients. I wanted to configure the server for Remote access with telnet application. I configured the server. But still I am not getting connected from the Client...
3
by: Dave | last post by:
Hi there. I'm a beginner at Python and I'm writing my first Python script. It's a text adventure about coffee and mixing drinks and being crazy and such. I keep updating it and want my friends to...
6
by: Joe | last post by:
Every thing I have fount was for C Sharp 2005, and I can't get any thing to work. Can some some show me a code for a telnet server in C Sharp 2008 that will a allow more then one connection.
3
by: Pvt Ryan | last post by:
Background: Due to the large number of bots attempting to ssh to my server, I implemented portknocking (as the logs were just filled with crap). So to access port 2222 for ssh I would first...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.