[Freeswitch-svn] [commit] r10905 - freeswitch/trunk/libs/esl/src

FreeSWITCH SVN mikej at freeswitch.org
Sun Dec 21 21:05:46 PST 2008


Author: mikej
Date: Mon Dec 22 00:05:44 2008
New Revision: 10905

Log:
SO_REUSEADDR on windows

Modified:
   freeswitch/trunk/libs/esl/src/esl.c

Modified: freeswitch/trunk/libs/esl/src/esl.c
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl.c	(original)
+++ freeswitch/trunk/libs/esl/src/esl.c	Mon Dec 22 00:05:44 2008
@@ -389,10 +389,20 @@
 	return esl_send_recv(handle, send_buf);
 }
 
+static int esl_socket_reuseaddr(esl_socket_t socket) 
+{
+#ifdef WIN32
+	BOOL reuse_addr = TRUE;
+	return setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse_addr, sizeof(reuse_addr));
+#else
+	int reuse_addr = 1;
+	return setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
+#endif
+}
+
 esl_status_t esl_listen(const char *host, esl_port_t port, esl_listen_callback_t callback)
 {
 	esl_socket_t server_sock = ESL_SOCK_INVALID;
-	int reuse_addr = 1;
 	struct sockaddr_in addr;
 	esl_status_t status = ESL_SUCCESS;
 	
@@ -400,8 +410,8 @@
 		return ESL_FAIL;
 	}
 
-	setsockopt(server_sock, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, sizeof(reuse_addr));
-			   
+	esl_socket_reuseaddr(server_sock);
+		   
 	memset(&addr, 0, sizeof(addr));
 	addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = htonl(INADDR_ANY);



More information about the Freeswitch-svn mailing list