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 function

wsaeventselect function

select() reports socket readable when:

  1. the socket listening , has pending inbound connection waiting accepted (fd_accept)
  2. the socket has pending data waiting read (fd_read). includes out-of-band data if so_oobinline option enabled on socket.
  3. the socket has been closed gracefully peer (fd_close, handles ungraceful closures well).

select() reports socket writable when:

  1. a non-blocking connect() has connected listening port (fd_connect 0 error code)
  2. 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:

  1. a non-blocking connect() has failed (fd_connect non-zero error code). can use getsockopt(sol_socket, so_error) error code.
  2. the socket has pending out-of-band data waiting read if so_oobinline option disabled on socket (fd_oob).
  3. 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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -