[xiph-commits] r7015 - in icecast/branches/kh: . net
brendan at dactyl.lonelymoon.com
brendan
Mon Jul 5 23:57:02 PDT 2004
Author: brendan
Date: Mon Jul 5 23:57:02 2004
New Revision: 7015
Added:
icecast/branches/kh/net/
Modified:
icecast/branches/kh/net/Makefile.am
icecast/branches/kh/net/resolver.c
icecast/branches/kh/net/sock.c
icecast/branches/kh/net/sock.h
Log:
KH branch of net module
Copied: icecast/branches/kh/net (from rev 7014, icecast/trunk/net)
Modified: icecast/branches/kh/net/Makefile.am
===================================================================
--- icecast/trunk/net/Makefile.am 2004-07-06 06:51:10 UTC (rev 7014)
+++ icecast/branches/kh/net/Makefile.am 2004-07-06 06:56:12 UTC (rev 7015)
@@ -9,6 +9,7 @@
libicenet_la_SOURCES = sock.c resolver.c
libicenet_la_CFLAGS = @XIPH_CFLAGS@
+AM_CPPFLAGS = @XIPH_CPPFLAGS@
INCLUDES = -I$(srcdir)/..
Modified: icecast/branches/kh/net/resolver.c
===================================================================
--- icecast/trunk/net/resolver.c 2004-07-06 06:51:10 UTC (rev 7014)
+++ icecast/branches/kh/net/resolver.c 2004-07-06 06:56:12 UTC (rev 7015)
@@ -203,7 +203,7 @@
if (!_initialized)
{
_initialized = 1;
- thread_mutex_create (&_resolver_mutex);
+ thread_mutex_create ("resolver", &_resolver_mutex);
/* keep dns connects (TCP) open */
#ifdef HAVE_SETHOSTENT
Modified: icecast/branches/kh/net/sock.c
===================================================================
--- icecast/trunk/net/sock.c 2004-07-06 06:51:10 UTC (rev 7014)
+++ icecast/branches/kh/net/sock.c 2004-07-06 06:56:12 UTC (rev 7015)
@@ -120,7 +120,7 @@
#endif
}
-static void sock_set_error(int val)
+void sock_set_error(int val)
{
#ifdef _WIN32
WSASetLastError (val);
@@ -396,9 +396,33 @@
}
-int sock_read_bytes(sock_t sock, char *buff, const int len)
+/* function to check if there are any pending reads on
+ * the stated socket. timeout in ms, 0 for immediate
+ * return
+ */
+int sock_read_pending(sock_t sock, unsigned timeout)
{
+ struct timeval tv;
+ fd_set rfds;
+ tv.tv_sec = timeout/1000;
+ tv.tv_usec = (timeout%1000)*1000;
+
+ FD_ZERO(&rfds);
+ FD_SET(sock, &rfds);
+
+ switch (select(sock + 1, &rfds, NULL, NULL, &tv))
+ {
+ case 0: return SOCK_TIMEOUT;
+ default: return 1;
+ case -1: return SOCK_ERROR;
+ }
+}
+
+
+int sock_read_bytes(sock_t sock, char *buff, size_t len)
+{
+
/*if (!sock_valid_socket(sock)) return 0; */
if (!buff) return 0;
if (len <= 0) return 0;
Modified: icecast/branches/kh/net/sock.h
===================================================================
--- icecast/trunk/net/sock.h 2004-07-06 06:51:10 UTC (rev 7014)
+++ icecast/branches/kh/net/sock.h 2004-07-06 06:56:12 UTC (rev 7015)
@@ -74,6 +74,7 @@
# define sock_shutdown _mangle(sock_shutdown)
# define sock_get_localip _mangle(sock_get_localip)
# define sock_error _mangle(sock_error)
+# define sock_set_error _mangle(sock_set_error)
# define sock_recoverable _mangle(sock_recoverable)
# define sock_stalled _mangle(sock_stalled)
# define sock_valid_socket _mangle(sock_valid_socket)
@@ -109,6 +110,7 @@
int sock_set_nolinger(sock_t sock);
int sock_set_keepalive(sock_t sock);
int sock_set_nodelay(sock_t sock);
+void sock_set_error(int val);
int sock_close(sock_t sock);
/* Connection related socket functions */
@@ -125,7 +127,7 @@
/* Socket read functions */
-int sock_read_bytes(sock_t sock, char *buff, const int len);
+int sock_read_bytes(sock_t sock, char *buff, size_t len);
int sock_read_line(sock_t sock, char *string, const int len);
/* server socket functions */
More information about the commits
mailing list