When the select
Linux system call returns when provided with valid file/socket writefds
, what are the write payload sizes for which a subsequent call to write will not block? E.g. is it 1B / 1kB / 1MB or some other threshold? And where is this threshold set?
int select(int nfds, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds, struct timeval *timeout);
what are the write payload sizes for which a subsequent call to write will not block?
In simple words, select
guarantees that the writable file is able to accommodate at least 1 byte without blocking.
Generally, after a successful select
call a single non-blocking write
call will succeed with any size of payload.
Note, however, that successful write could return just 1 with meaning that only 1 byte has been actually written. For write the rest bytes a write
call should be repeated, but that second write
is allowed to block (or return EWOULDBLOCK if called on non-blocking file descriptor).