Enable TCP socket option KEEPALIVE

RCF support and general discussion.
Post Reply
falk
Posts: 8
Joined: Fri Mar 30, 2012 2:31 pm

Enable TCP socket option KEEPALIVE

Post by falk »

Hello Jarl and all others,
here is a question about the possibility of enabling keep-alive packets for socket connections on client-side.
The goal is that the client will be notified via the TCP keep-alive feature if a connection faces problems.

With access to the underlying native handler and some modifications to RCF 2.1.0.0 it was possible to implement this feature under Windows. Can you take a look at the code patch and tell me if you see any impacts for the other RCF functionality?
One important point is that the Win-function WSAAsyncSelect converts blocking sockets into nonblocking. But since the method TcpClientTransport::setupSocket makes this anyway, i do not think thats an issue.

There is a server and a client programm attached too to test the keep-alive. Run the server and the client (maybe adjust the hardcoded ip in the sources before) and then pull a cable somewhere between the client and server. After a timeout of five seconds the client will receive a notification that the connection is closed. This notification is tested with a read on the socket which results in an socket error (WSAECONNRESET).
Attachments
wsanotification.patch
(2.36 KiB) Downloaded 459 times
wsaNotificationExample.zip
(3.02 KiB) Downloaded 451 times

Post Reply