--- a/mb_tcp.c Sun Jun 06 22:52:40 2021 +0100
+++ b/mb_tcp.c Mon Jun 07 11:21:26 2021 +0200
@@ -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,