summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsanikoyes <sanikoyes@163.com>2015-10-13 13:11:33 +0800
committersanikoyes <sanikoyes@163.com>2015-10-13 13:11:33 +0800
commit15f69910646cf3643ec24c05019971950b7738ae (patch)
tree6326dfbbb168569e98894c1cd02b2c7dd10a9851
parentb3cda43a0fb49e1cb9c8414077a23fa4b61ede38 (diff)
REUSE_ADDR under windows platform
-rw-r--r--platform/windows/tcp_server_winsock.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/windows/tcp_server_winsock.cpp b/platform/windows/tcp_server_winsock.cpp
index bf7e85aebb..cc689d9dcf 100644
--- a/platform/windows/tcp_server_winsock.cpp
+++ b/platform/windows/tcp_server_winsock.cpp
@@ -79,6 +79,13 @@ Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_ho
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP TODO: use p_accepted_hosts
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
+ int reuse=1;
+ if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse, sizeof(reuse)) < 0) {
+
+ printf("REUSEADDR failed!");
+ }
+
+
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) != SOCKET_ERROR) {
if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {