Add KeepAlive support for all TCP sockets.
--- a/mb_tcp.c Mon Jun 01 14:28:49 2020 +0100
+++ b/mb_tcp.c Mon Mar 22 14:57:48 2021 +0100
@@ -467,6 +467,18 @@
}
/* configure the socket */
+ {
+ int optval;
+ socklen_t optlen = sizeof(optval);
+ optval = 1;
+ if(setsockopt(socket_id, SOL_SOCKET, SO_KEEPALIVE, &optval, optlen) < 0) {
+#ifdef ERRMSG
+ perror("setsockopt()");
+ fprintf(stderr, ERRMSG_HEAD "Error configuring socket 'KeepAlive' option.\n");
+#endif
+ return -1;
+ }
+ }
/* set the TCP no delay flag. */
{int bool_opt = 1;
if (setsockopt(socket_id, SOL_TCP, TCP_NODELAY,