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:

  1. the presence of out-of-band data when so_oobinline not enabled.

  2. detect non-blocking connect() failure on windows. if connection successful, socket put write_fds, otherwise put except_fds instead. documented on msdn select() 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 socket write_fds regardless of whether connection succeeded or failed, have query error code differentiate. documented on linux man page connect(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).


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -