disconnecting from Flex TCP server

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a simple client that connects via TCP and issues commands from the ethernet API. When this client closes the TCP connection and then later attempts to connect again, that attempt is rebuffed until some time passes, or until SmartSDR is terminated and restarted. The API documentation does not include a "terminate connection" command, but does include a "keepalive" command that refers to a "TCP/IP channel keepalive system" for which I cannot locate documentation.

What's the appropriate procedure for a client to terminate the TCP connection in a way that permits a new connection to be created without delay?
Photo of Dave AA6YQ

Dave AA6YQ

  • 95 Posts
  • 54 Reply Likes

Posted 3 years ago

  • 1
Photo of Ed.G

Ed.G, Software Engineer

  • 88 Posts
  • 20 Reply Likes
Official Response
If the TCP socket is closed properly on the client side then you should be able to re-connect immediately. If it is not then the radio tries to cleanup in a couple different ways. 

If your client enables the keep-alive mechanism then the radio will timeout and close the socket after 15 seconds. If your client did not enable keep-alive then the radio will close the socket if it can't communicate with your client after several attempts or if Linux closes the socket. This second method of cleanup does not have a hard time limit so it could take anywhere from a couple seconds to a couple minutes. 

The keep-alive system works as follows:

A client must send the command "keepalive enable" and then send a "ping" command every second. If the radio does not receive a "ping" command from a client for 15 seconds then that client is disconnected and the socket is closed.