On 2015-01-15 12:42, Rafał Miłecki wrote: > Signed-off-by: Rafał Miłecki <zaj...@gmail.com> > --- > usock.c | 30 ++++++++++++++++++++++++++++++ > usock.h | 11 +++++++++++ > 2 files changed, 41 insertions(+) > > diff --git a/usock.c b/usock.c > index 04ed4ee..39909c1 100644 > --- a/usock.c > +++ b/usock.c > @@ -117,3 +117,33 @@ int usock(int type, const char *host, const char > *service) { > usock_set_flags(sock, type); > return sock; > } > + > +int usock_wait_ready(int fd, int msecs) { > + fd_set fds; > + struct timeval tv; > + int res; > + > + FD_ZERO(&fds); > + FD_SET(fd, &fds); > + > + tv.tv_sec = msecs / 1000; > + tv.tv_usec = (msecs % 1000) * 1000; > + > + res = select(fd + 1, NULL, &fds, NULL, &tv); Wouldn't it be better to use poll() here? The fd bitmask crap that select uses is quite ugly.
- Felix _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel