int nopoll_conn_flush_writes ( noPollConn conn,
long  timeout,
int  previous_result 
)

Ready to use function that checks for pending write operations and flush them waiting until they are done or until the timeout provided by the user is reached.

This function uses nopoll_conn_pending_write_bytes and nopoll_conn_complete_pending_write to check and complete pending write operations.

Because writing pending bytes is a common operation, this function is provided as a ready to use function to call after a write operation (for example nopoll_conn_send_text).

Parameters
connThe connection where pending bytes must be written.
timeoutTimeout in microseconds to limit the flush operation.
previous_resultOptional parameter that can receive the number of bytes optionally read before this call. The value received on this function will be added to the result, checking first it contains a value higher than 0. This is an option to clarify the interface. If you don't have the value to be passed to this function at the time needed, just pass 0.
Returns
Bytes that were written. If no pending bytes must be written, the function returns 0. The function returns bytes written or bytes written plus if previous_result is > 0.

References nopoll_conn_complete_pending_write(), nopoll_conn_pending_write_bytes(), NOPOLL_EWOULDBLOCK, NOPOLL_LEVEL_DEBUG, and nopoll_sleep().