REUSE_ADDR under windows platform
This commit is contained in:
parent
b3cda43a0f
commit
15f6991064
1 changed files with 7 additions and 0 deletions
|
@ -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
|
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);
|
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 (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) != SOCKET_ERROR) {
|
||||||
|
|
||||||
if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {
|
if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {
|
||||||
|
|
Loading…
Reference in a new issue