Ignore error setting socket option SO_REUSEADDR
Shouldn't fail. If it fails, but bind() works, the failure doesn't matter. If bind() fails, we can just as well report that failure instead of setsockopt()'s.
This commit is contained in:
parent
8233c06317
commit
75be45f1e4
1 changed files with 2 additions and 4 deletions
|
@ -81,8 +81,7 @@ tcp_listen(char *host, char *serv, size_t *addrlenp)
|
|||
if (fd < 0)
|
||||
continue; /* error, try next one */
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
|
||||
cant_listen(host, serv, strerror(errno));
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
if (bind(fd, ai->ai_addr, ai->ai_addrlen) == 0)
|
||||
break; /* success */
|
||||
|
||||
|
@ -127,8 +126,7 @@ tcp_listen(char *host, char *serv, size_t *addrlenp)
|
|||
}
|
||||
if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
||||
cant_listen(host, serv, strerror(errno));
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
|
||||
cant_listen(host, serv, strerror(errno));
|
||||
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
cant_listen(host, serv, strerror(errno));
|
||||
if (listen(fd, SOMAXCONN) < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue