This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

TCP keep alives

I have a problem with the TCP connection being dropped. The far end drops the connection after a few minutes.

I believe I need to send TCP keepalives periodically to stop the connection from dropping, but I don't see a way to do this. I tried sending a zero length buffer to tcp_send() (with the 3rd param set to 0). That didn't seem to do anything.

Then I tried sending one byte of garbage data periodically, and this keeps the connection up.

I don't want to send garbage. How can I send a proper keepalive (an empty packet with the ACK flag set)?

Dave

Parents
  • I am writing an FTP client. The control socket times out before the data socket has finished transferring data. I will have to find some sequence to send which is harmless to the FTP server. I don't have control over which FTP server will be used. This doesn't seem good to me.

    Do you know if Keil is planning to support tcp keepalive at some point?

    Dave

Reply
  • I am writing an FTP client. The control socket times out before the data socket has finished transferring data. I will have to find some sequence to send which is harmless to the FTP server. I don't have control over which FTP server will be used. This doesn't seem good to me.

    Do you know if Keil is planning to support tcp keepalive at some point?

    Dave

Children
  • You can send STAT command during a file transfer. It will be used for a harmless keep-alive data transfer in your case.

    RFC 959 says:

    This command shall cause a status response to be sent over the control connection
    in the form of a reply. The command may be sent during a file transfer (along
    with the Telnet IP and Synch signals--see the Section on FTP Commands) in which
    case the server will respond with the status of the operation in progress,
    or it may be sent between file transfers.
    

  • Thanks. That would work, or perhaps a telnet negotiation sequence like IAC NOP. There are ways around it.

    Dave