mirror of
https://gitlab.xiph.org/xiph/icecast-common.git
synced 2025-02-02 15:07:47 -05:00
Ricardo Galli found this too. We weren't setting no linger and keepalive
as we used to in icecast1. They make things work a bit better. svn path=/trunk/net/; revision=3177
This commit is contained in:
parent
c8b2e41e67
commit
366d560cde
17
net/sock.c
17
net/sock.c
@ -177,6 +177,18 @@ int sock_set_blocking(sock_t sock, const int block)
|
||||
#endif
|
||||
}
|
||||
|
||||
int sock_set_nolinger(sock_t sock)
|
||||
{
|
||||
struct linger lin = { 0, 0 };
|
||||
return setsockopt(sock, SOL_SOCKET, SO_LINGER, (void *)&lin, sizeof(struct linger));
|
||||
}
|
||||
|
||||
int sock_set_keepalive(sock_t sock)
|
||||
{
|
||||
int keepalive = 1;
|
||||
return setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(int));
|
||||
}
|
||||
|
||||
/* sock_close
|
||||
**
|
||||
** close the socket
|
||||
@ -477,8 +489,11 @@ int sock_accept(sock_t serversock, char *ip, int len)
|
||||
slen = sizeof(struct sockaddr_in);
|
||||
ret = accept(serversock, (struct sockaddr *)&sin, &slen);
|
||||
|
||||
if (ret >= 0 && ip != NULL)
|
||||
if (ret >= 0 && ip != NULL) {
|
||||
strncpy(ip, inet_ntoa(sin.sin_addr), len);
|
||||
sock_set_nolinger(ret);
|
||||
sock_set_keepalive(ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -43,6 +43,8 @@ int sock_error(void);
|
||||
int sock_recoverable(int error);
|
||||
int sock_valid_socket(sock_t sock);
|
||||
int sock_set_blocking(sock_t sock, const int block);
|
||||
int sock_set_nolinger(sock_t sock);
|
||||
int sock_set_keepalive(sock_t sock);
|
||||
int sock_close(sock_t sock);
|
||||
|
||||
/* Connection related socket functions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user