Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, I've been trying to write a simple telnet program using C. When I examined the cmd telnet I realised that it sends single characters, meaning char by char. My first question is why is that? Second question is do I have to do the same in my C program? And also, how to I use input in C without pressing ENTER?
Posted
Comments
CodingLover 4-Sep-12 5:34am    
Why don't you show that what you have done so far. It's easy to comment.
Mohibur Rashid 4-Sep-12 5:57am    
well, if you read the protocol for ssh you would find that there is lots of situation where protocol does not use null terminated string. if you send data after every keyboard action it might be hard for you to debug. such as if you are testing a HTTP data transfer and you start with GET and then you realize you want to send POST then it will be a error already. but you are developing why dont you test and confirm which one is best suite for you.

Hey why dont you look at putty and see what it does.

Telnet can be used to connect to a remote shell. With shells, you expect that each typed character is echoed on the screen. To achieve this with remote connections, each single character must be send to the server which will echo it back to the client for display on the client's screen.

If you want to write a standard compliant Telnet client, you have to do the same.

To read single characters from the keyboard, use the getch() function (_getch() with Visual Studio compilers).
 
Share this answer
 
Answer to the third question only
Regarding the capture of chars without pressing enter, I believe "getch" or "getche" do that, take a look at it.

http://msdn.microsoft.com/en-us/library/kswce429(v=vs.80).aspx[^]

Regarding the other questions...
http://www.codeproject.com/search.aspx?q=telnet&sbo=kw&x=0&y=0[^]
I've found several articles about telnet apps here in CP... probably some of them will give you pointers on how to proceed.

Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900