Telnet TCP Client

Discussion to talk about software related topics only.
Post Reply
BMillikan
Posts: 14
Joined: Thu Dec 23, 2010 7:56 am

Telnet TCP Client

Post by BMillikan »

I am trying to build a simple Telnet client on the Netburner board. I am simply using the connect(..) call on port 23. However, if I try to re-connect after a power cycle or reset the connect(...) function hangs forever or times out. Is there any way to reset this connection so that I can communicate with the device? I can switch to a PC and open up a telnet window with no problem without power cycling the device. The "device" being the terminal that I'm trying to communicate to through telnet.

Thanks,
Brian
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: Telnet TCP Client

Post by rnixon »

You need to close the connection using the close() command. If you don't, the device you are connecting to will still think the session is valid (half open socket).
BMillikan
Posts: 14
Joined: Thu Dec 23, 2010 7:56 am

Re: Telnet TCP Client

Post by BMillikan »

How do you close the connect if the board has been reset? You lose the file descriptor, right?
thomastaranowski
Posts: 82
Joined: Sun May 11, 2008 2:17 pm
Location: Los Angeles, CA
Contact:

Re: Telnet TCP Client

Post by thomastaranowski »

Yeah, you lose the descriptor so you can't close it on the client end. It's kind of a long standing issue with telnet and ftp servers. Most of them are smart enough to timeout the server socket so you don't exhaust the servers pool of available sockets. You could try using a keepalive option on the server side to improve timeout performance. It's not clear why you can't reconnect the client, though. If you are binding your local client socket to port 23, and connecting to port 23, the server(or maybe an intermediate firewall) might be confused and think the connection is already up, since both ends of the socket will be identical. You might try binding to a different random local port for your client to see if that alleviates the problem. The keepalive on the server side feels like a better solution though.
Post Reply