From 573d203344b9f2c283f8b7bdc9c4bebed4725757 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 17 Sep 2016 12:28:56 -0300 Subject: [PATCH] socket options --- iguana/iguana_peers.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 0369bf5fe..a1750752f 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -387,18 +387,16 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) #ifndef WIN32 if ( 1 )//&& bindflag != 0 ) { - if ( 1 ) - { - timeout.tv_sec = 0; - timeout.tv_usec = 30000; - setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); - } opt = 0; getsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,(void *)&opt,&slen); opt = 1; //printf("keepalive.%d\n",opt); - } else setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)); + } + setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(void *)&opt,sizeof(opt)); #ifdef __APPLE__ + timeout.tv_sec = 0; + timeout.tv_usec = 30000; + setsockopt(sock,SOL_SOCKET,SO_RCVTIMEO,(void *)&timeout,sizeof(timeout)); timeout.tv_sec = 0; timeout.tv_usec = 10000; setsockopt(sock,SOL_SOCKET,SO_SNDTIMEO,(void *)&timeout,sizeof(timeout));