mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Reuse socket address
To avoid having to wait for socket timeout when restarting server.
This commit is contained in:
parent
134038c1ce
commit
bed34a0b9a
1 changed files with 7 additions and 0 deletions
|
|
@ -124,6 +124,7 @@ void socket_configure(void)
|
|||
struct sockaddr_in6 sockaddr_inet6 = {};
|
||||
struct sockaddr *sockaddr_p;
|
||||
socklen_t socklen;
|
||||
int optval;
|
||||
|
||||
/* Parse socket string */
|
||||
|
||||
|
|
@ -225,6 +226,12 @@ void socket_configure(void)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)))
|
||||
{
|
||||
tio_error_printf("Failed to set socket options (%s)", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Bind */
|
||||
if (bind(sockfd, sockaddr_p, socklen) < 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue