... | ... |
@@ -231,6 +231,19 @@ sock_setblocking(int fd, int block) |
231 | 231 |
return(fcntl(fd,F_SETFL,fl)); |
232 | 232 |
} |
233 | 233 |
|
234 |
+int |
|
235 |
+sock_readable(int fd) /* tests readability */ |
|
236 |
+{ |
|
237 |
+ struct timeval tv; |
|
238 |
+ fd_set rset; |
|
239 |
+ FILLTV(tv,0,0); |
|
240 |
+ FD_ZERO(&rset); |
|
241 |
+ FD_SET(fd,&rset); |
|
242 |
+ if(select(fd+1,&rset,NULL,NULL,&tv)>0) |
|
243 |
+ return(0); |
|
244 |
+ return(-1); |
|
245 |
+} |
|
246 |
+ |
|
234 | 247 |
sselect * |
235 | 248 |
sselect_init(void) |
236 | 249 |
{ |
... | ... |
@@ -32,6 +32,7 @@ int sock_accept(int fd); |
32 | 32 |
int sock_getinfo(int fd, int *iplen, char *ip, int *port); /* ip must be at least 16 bytes to have room for an ipv6 address */ |
33 | 33 |
int sock_queued(int fd); |
34 | 34 |
int sock_setblocking(int fd, int block); |
35 |
+int sock_readable(int fd); |
|
35 | 36 |
|
36 | 37 |
sselect *sselect_init(void); |
37 | 38 |
void sselect_free(sselect *ssel); |