diff --git a/src/itscp_core.c b/src/itscp_core.c index 1646d540d20a3e41bf2588f72e3ca5f72c7ef509..f232f66544aef09675a574d3e51bdc4df5eb0fa1 100644 --- a/src/itscp_core.c +++ b/src/itscp_core.c @@ -144,6 +144,13 @@ int itscp_listen(ITSCPContext *ctx) { goto DONE; } + int optval = 1; + if (setsockopt(ctx->sock_main, SOL_SOCKET, SO_REUSEADDR, (const char*)&optval, sizeof(optval)) == -1) { + printf("setsockopt failed\n"); + ret = -1; + goto DONE; + } + if (listen(ctx->sock_main, SOMAXCONN) < 0) { printf("itscp_listen: socket listen failed\n"); ret = -1;