-
recv() and telnet ?
I am writing a server, to be remotly connected through a telnet client.
Now, the problem is that when I type a single char in the telnet client, it doesn't waits for me to hit ENTER, but sends it right away.
My question is: how can I make my program wait until ENTER is been pressed in the telnet client, so the entire string before I hitted ENTER will be saved in a single string variable (in the server).
I tried this, but no luck...
while (msg[0]!='\n')
recv(sockfd, msg, 100, 0);
I'm still new to network programming;
Please help, thanks in advance.
-
I'm not sure I understand.
You have written the Telenet client or are using someone elses?
You want to know when the client has sent a full sentance and the sentance has been received by the server?
Does the client send anything when you just hit enter (or could you set it up so it did)?
ie a code so you know it is a new line / end of line or send the size (strlen() ) of the message first.
-
nonononono
no no...
I'm using the windows' telnet client.
and I'm writing my own server, in C.
when I connect my server with telnet, I can only type one char into the client before it will auto sends it to the server (before I hit ENTER).
The question is, how can my server tell, when I hit ENTER in the telnet client?
this is what I want to do:
Code:
recv(sockfd, msg, 100, 0);
if (strcmp(msg, "yes"))
send(sockfd, "yes\n\r", 5, 0);
*note: I checked what the msg is receiving, and that is only one char, instead of a string.
thanks.
-
Thanks... the strchr did the trick... but the question is...
why the windows telnet client sends it char by char...
and the *nix sends it string by string?
-