[zeromq-dev] help, test and review request: new setsockopt(ZMQ_TCP_KEEPALIVE)

Sergey Hripchenko shripchenko at intermedia.net
Thu Apr 5 18:26:34 CEST 2012

Could you please look at the following patch: https://github.com/shripchenko/libzmq/commit/0c3d9179262ab431b8949b8646eed9a1a1e4a233

to configure TCP keep-alives on TCP sockets(keep-alives are fully transparent to the program and functions like select(), poll(), e.t.c.)
They all defaults to -1 which means ignore them and leave it all for OS defaults.
If some of them not supported by OS then zmq->socket()->setsockopt(ZMQ_TCP_KEEPALIVE*) call will return 0 but leave option = -1.

The big problem here is that although SO_KEEPALIVE is cross-platform safe(at least Internet said so, but still needs to be tested on all platforms),
All other options like TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL work on linux, possibly work in *bsd and will not work on windows in current implementation.

On windows it could be done with this code:

tcp_keepalive alive;

alive.onoff = TRUE;

alive.keepalivetime = 60000;

alive.keepaliveinterval = 1000;

int bytes_ret=0;

res = WSAIoctl(socket, SIO_KEEPALIVE_VALS, &alive, sizeof(alive), NULL, 0,

    &bytes_ret, NULL, NULL);

Unfortunately I have no windows knowledge, so could someone please help me to modify this patch to work on windows.


And test it on other platforms.


This message is intended only for the person(s) to which it is addressed and may contain Intermedia.net Inc privileged, confidential and/or proprietary information. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Any disclosure, copying, distribution, or the taking of any action concerning the contents of this message and any attachment(s) by anyone other than the named recipient(s) is strictly prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120405/e1ba39a7/attachment.htm>

More information about the zeromq-dev mailing list