winapi - How to map events of POSIX's select and Windows WSAEventSelect -
posix's select allows determine 3 events:
- read
- write
- error
window's wsaeventselect has 10:
- fd_read
- fd_write
- fd_oob
- fd_accept
- fd_connect
- fd_close
- fd_qos
- fd_group_qos
- fd_routing_interface_change
- fd_address_list_change
how can map windows events posix events?
edit
unfortunately cannot use windows's implementation of select because of multiple providers restriction.
the mapping between select() , wsaeventselect() not hard figure out if read documentation.
select() reports socket readable when:
- the socket listening , has pending inbound connection waiting accepted (
fd_accept) - the socket has pending data waiting read (
fd_read). includes out-of-band data ifso_oobinlineoption enabled on socket. - the socket has been closed gracefully peer (
fd_close, handles ungraceful closures well).
select() reports socket writable when:
- a non-blocking
connect()has connected listening port (fd_connect0 error code) - the socket has buffer space accept outbound data (
fd_write) after being accepted, or after previous non-blocking send no longer block.
select() reports exception on socket when:
- a non-blocking
connect()has failed (fd_connectnon-zero error code). can usegetsockopt(sol_socket, so_error)error code. - the socket has pending out-of-band data waiting read if
so_oobinlineoption disabled on socket (fd_oob). - various socket errors have occurred.
there no select() equivalents rest of wsa events, strictly winsock-specific extensions not related posix/bsd socket apis.
so, use wsaeventselect() setup desired fd_... events, wait on events using wsawaitformultipleevents(). when event signaled, use wsaenumnetworkevents() associated error codes , clear event state next wait.
Comments
Post a Comment