[xiph-cvs] cvs commit: net sock.c sock.h
Jack Moffitt
jack at xiph.org
Fri Mar 22 13:44:30 PST 2002
jack 02/03/22 13:44:30
Modified: . sock.c sock.h
Log:
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.
Revision Changes Path
1.5 +16 -1 net/sock.c
Index: sock.c
===================================================================
RCS file: /usr/local/cvsroot/net/sock.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- sock.c 2002/03/22 21:24:57 1.4
+++ sock.c 2002/03/22 21:44:29 1.5
@@ -177,6 +177,18 @@
#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 @@
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;
}
<p><p>1.4 +2 -0 net/sock.h
Index: sock.h
===================================================================
RCS file: /usr/local/cvsroot/net/sock.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- sock.h 2002/02/07 01:04:08 1.3
+++ sock.h 2002/03/22 21:44:29 1.4
@@ -43,6 +43,8 @@
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 */
<p><p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list