diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-02-04 14:29:11 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-02-04 14:29:11 +0000 |
commit | 0b2542d1a61fc5425ff65ab3dbf7ba7de174763f (patch) | |
tree | 8a6188e11db0c9ef6891c31e8a1bebca050b23b2 /src/usocket.c | |
parent | f67864f86c7d703325e86b14d0ba33992c52891b (diff) | |
download | luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.tar.gz luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.tar.bz2 luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.zip |
Worked on the manual.
Implemented stuffing (needs test)
Added cddb and qp examples.
Diffstat (limited to 'src/usocket.c')
-rw-r--r-- | src/usocket.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/usocket.c b/src/usocket.c index bece354..eb1a49a 100644 --- a/src/usocket.c +++ b/src/usocket.c | |||
@@ -70,12 +70,10 @@ int sock_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, int timeout) | |||
70 | \*-------------------------------------------------------------------------*/ | 70 | \*-------------------------------------------------------------------------*/ |
71 | const char *sock_create(p_sock ps, int domain, int type, int protocol) | 71 | const char *sock_create(p_sock ps, int domain, int type, int protocol) |
72 | { | 72 | { |
73 | int val = 1; | ||
74 | t_sock sock = socket(domain, type, protocol); | 73 | t_sock sock = socket(domain, type, protocol); |
75 | if (sock == SOCK_INVALID) return sock_createstrerror(errno); | 74 | if (sock == SOCK_INVALID) return sock_createstrerror(errno); |
76 | *ps = sock; | 75 | *ps = sock; |
77 | sock_setnonblocking(ps); | 76 | sock_setnonblocking(ps); |
78 | setsockopt(*ps, SOL_SOCKET, SO_REUSEADDR, (char *) &val, sizeof(val)); | ||
79 | return NULL; | 77 | return NULL; |
80 | } | 78 | } |
81 | 79 | ||
@@ -167,13 +165,14 @@ const char *sock_accept(p_sock ps, p_sock pa, SA *addr, | |||
167 | for (;;) { | 165 | for (;;) { |
168 | int err; | 166 | int err; |
169 | fd_set fds; | 167 | fd_set fds; |
168 | /* try to accept */ | ||
170 | *pa = accept(sock, addr, addr_len); | 169 | *pa = accept(sock, addr, addr_len); |
171 | /* if result is valid, we are done */ | 170 | /* if result is valid, we are done */ |
172 | if (*pa != SOCK_INVALID) return NULL; | 171 | if (*pa != SOCK_INVALID) return NULL; |
173 | /* find out if we failed for a fatal reason */ | 172 | /* find out if we failed for a fatal reason */ |
174 | if (errno != EWOULDBLOCK && errno != ECONNABORTED) | 173 | if (errno != EWOULDBLOCK && errno != ECONNABORTED) |
175 | return sock_acceptstrerror(errno); | 174 | return sock_acceptstrerror(errno); |
176 | /* call select just to avoid busy-wait. */ | 175 | /* call select to avoid busy-wait. */ |
177 | FD_ZERO(&fds); | 176 | FD_ZERO(&fds); |
178 | FD_SET(sock, &fds); | 177 | FD_SET(sock, &fds); |
179 | do err = sock_select(sock+1, &fds, NULL, NULL, tm_getretry(tm)); | 178 | do err = sock_select(sock+1, &fds, NULL, NULL, tm_getretry(tm)); |