How to determine if I can write the given number of bytes to a filehandle (socket actually)? (Alternatively, how to "unread" the data I had read from other filehandle?)
I want something like:
n = how_much_can_I_write(w_handle); n = read(r_handle, buf, n); assert(n==write(w_handle, buf, n));
Both filehandles (r_handle and w_handle) have received ready status from epoll_wait.
I want all data from r_handle to be copied to w_handle without using a "write debt" buffer.
In general, how to copy the data from one filehandle to the other simply and reliably?
@related http://stackoverflow.com/questions/2677262/how-can-i-interconnect-two-sockets-in-linux