Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C
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 3-Sep-12 23:33pm
DanDv242
Comments
CodingLover at 4-Sep-12 5:34am
   
Why don't you show that what you have done so far. It's easy to comment.
Mohibur Rashid at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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).
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
0 CHill60 360
1 Sarvesh Kumar Gupta 238
2 OriginalGriff 193
3 Sergey Alexandrovich Kryukov 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 4 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid