Adam Mallory <firstname.lastname@example.org> wrote:
Xiaodan Tang <> email@example.com> > wrote in news:a5kov9$rgn$> firstname.lastname@example.org> :
ran zhang <> email@example.com> > wrote:
how would i modify the code to do a timeout?
msgsock = accept (sock, 0, 0) ;
int on = 1;
setsockopt (msgsock , SOL_SOCKET, SO_KEEPALIVE, (char *)&on,
Socket option TCP_KEEPALIVE to change that 2 hour.
Check the document for “tcp”.
I just don’t like advocating the use of this as a mechanism for timing out
sockets. It’s usually a system wide attribute - hence the use of a heart
beat using OBD (or some other mechanism you can cook up) IMHO is better. I
agree it’s not always do-able, but without context in this case, I would
err on the side of caution.
Adam, I don’t have source to confirm, but TCP_KEEPALIVE IS socket
This is an option that implemented by QSSL.