Click here to Skip to main content
12,693,693 members (28,454 online)
Rate this:
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 4-Sep-12 0:33am
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.
Rate this: bad
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).
Rate this: bad
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.[^]

Regarding the other questions...[^]
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100