diff options
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/mcmc/mcmc.c | 10 | ||||
-rw-r--r-- | vendor/mcmc/mcmc.h | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/vendor/mcmc/mcmc.c b/vendor/mcmc/mcmc.c index 65b7e68..e62cdea 100644 --- a/vendor/mcmc/mcmc.c +++ b/vendor/mcmc/mcmc.c @@ -454,7 +454,15 @@ int mcmc_connect(void *c, char *host, char *port, int options) { if (sock == -1) continue; - // TODO: NONBLOCK + if (options & MCMC_OPTION_TCP_KEEPALIVE) { + int optval = 1; + if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) { + res = MCMC_ERR; + close(sock); + goto end; + } + } + if (options & MCMC_OPTION_NONBLOCK) { int flags = fcntl(sock, F_GETFL); if (flags < 0) { diff --git a/vendor/mcmc/mcmc.h b/vendor/mcmc/mcmc.h index 1769228..dba159a 100644 --- a/vendor/mcmc/mcmc.h +++ b/vendor/mcmc/mcmc.h @@ -37,6 +37,7 @@ #define MCMC_OPTION_BLANK 0 #define MCMC_OPTION_NONBLOCK 1 +#define MCMC_OPTION_TCP_KEEPALIVE (1<<1) // convenience defines. if you want to save RAM you can set these smaller and // error handler will only copy what you ask for. |