1
0
mirror of https://gitlab.xiph.org/xiph/icecast-common.git synced 2024-06-16 06:15:24 +00: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:
Jack Moffitt 2002-03-22 21:44:29 +00:00
parent c8b2e41e67
commit 366d560cde
2 changed files with 18 additions and 1 deletions

View File

@ -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;
}

View File

@ -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 */