-
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.
-
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';
-