7 int io_poll(int fd
, int events
, int msec
)
14 return poll(&pfd
, 1, msec
);
17 int io_send_all(int fd
, const void *buf
, size_t len
)
19 int poll_ret
, sent
, loops
= 0;
25 poll_ret
= io_poll(fd
, POLLOUT
, 0);
27 lerr("io_poll(%d, POLLOUT, 0) returned %d: %s", fd
, poll_ret
, strerror(errno
));
31 sent
= send(fd
, buf
+ total
, len
- total
, MSG_DONTWAIT
);
32 if (poll_ret
> 0 && sent
+ total
== 0) {
33 /* disconnected peer? */
37 if (errno
== EAGAIN
|| errno
== EWOULDBLOCK
) {
38 sent
= io_write_ok(fd
, 100);
42 lerr("send(%d, (buf + total), %zu, MSG_DONTWAIT) returned %d (%s)",
43 fd
, len
- total
, sent
, strerror(errno
));
48 } while (total
< len
&& sent
> 0 && loops
< 15);