Determine how much can I write into a filehandle; copying data from one FH to the other.
Posted
by Vi
on Stack Overflow
See other posts from Stack Overflow
or by Vi
Published on 2010-04-20T09:37:04Z
Indexed on
2010/04/20
10:13 UTC
Read the original article
Hit count: 260
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?
© Stack Overflow or respective owner