c++ - What is exceptional condition pending fd in select function? -
the prototype select function is
select(int no_of_fd,fd_set read_fds,fd_set write_fds,fd_set expection_condition_fd,const struct timeval *timeout) what exception condition fd's represent?
when fd set ?
it used to:
the presence of out-of-band data when
so_oobinlinenot enabled.detect non-blocking
connect()failure on windows. if connection successful, socket putwrite_fds, otherwise putexcept_fdsinstead. documented on msdnselect()function:in summary, socket identified in particular set when select returns if:
readfds:
- if listen has been called , connection pending, accept succeed.
- data available reading (includes oob data if so_oobinline enabled).
- connection has been closed/reset/terminated.
writefds:
- if processing connect call (nonblocking), connection has succeeded.
- data can sent.
exceptfds:
- if processing connect call (nonblocking), connection attempt failed.
- oob data available reading (only if so_oobinline disabled).
in case of failure, can query socket particular error code using
getsockopt(sol_socket, so_error), if needed.on other platforms, such linux,
select()puts socketwrite_fdsregardless of whether connection succeeded or failed, have query error code differentiate. documented on linux man pageconnect(2)function:return value
if connection or binding succeeds, 0 returned. on error, -1 returned, , errno set appropriately.
...
einprogress
socket nonblocking , connection cannot completed immediately. it possible select(2) or poll(2) completion selecting socket writing. after select(2) indicates writability, use getsockopt(2) read so_error option @ level sol_socket determine whether connect() completed (so_error zero) or unsuccessfully (so_error 1 of usual error codes listed here, explaining reason failure).- if listen has been called , connection pending, accept succeed.
Comments
Post a Comment