Thread: Telnet connections

  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    102

    Telnet connections

    Hello, my program listens on port 23 for telnet connections, it works fine accept for when I try to recieve some data. It recieves the correct data, but it also fills up the rest of the buffer with useless junk. How do I stop it sending me all this rubbish? Or is there a way to filter out the actual data?

    thanks everybody.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Use the length returned by the recv() call rather than assuming that a \0 always exists in the place you expect it to.

    Code:
    char buff[BUFSIZ];
    int n = recv( fd, buff, BUFSIZ-1, 0 );  // allow for adding a \0
    if ( n > 0 ) buff[n] = '\0';

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    102
    thank you very much.

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 Function Telnet Email
    By karcheee in forum C Programming
    Replies: 3
    Last Post: 07-25-2005, 11:39 AM
  3. C Execl Telnet
    By karcheee in forum C Programming
    Replies: 1
    Last Post: 04-26-2005, 02:31 PM
  4. telnet!!
    By bigB8210 in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-13-2003, 05:09 PM
  5. Multiple Client Connections
    By (TNT) in forum Windows Programming
    Replies: 1
    Last Post: 04-06-2002, 11:04 PM