Thread: recv() and telnet ?

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Question 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 don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    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.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    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.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    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?
    Last edited by Devil Panther; 06-13-2003 at 05:01 AM.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  5. #5
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    thanks again
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with telnet and tcp
    By hoAx in forum Windows Programming
    Replies: 11
    Last Post: 03-11-2008, 02:03 PM
  2. C Sockets - recv() problem
    By Mercurius in forum Networking/Device Communication
    Replies: 3
    Last Post: 05-15-2006, 07:49 AM
  3. recv() problem:(
    By piotrek_no_1 in forum Networking/Device Communication
    Replies: 5
    Last Post: 05-12-2005, 11:52 PM
  4. Server recv data problem! Please help!
    By hyaku_ in forum Networking/Device Communication
    Replies: 15
    Last Post: 01-28-2005, 02:35 PM