0
votes

I've a non-blocking socket used for writing operations (send).

I would like to know if the select() is the only way to detect if: - the socket connect completed successfully when connect returns EINPROGRESS - the availability of socket for write operations when send return EWOULDBLOCK or EGAIN

Is polling an alternative to select()? In my application I've already a thread that wakes up each 1 second that can check cyclically if connect() returns with 0 (connection is OK) and send returns with 0 (sending is OK) if some bytes have to be sent.

1

1 Answers

0
votes

Is polling an alternative to select()?

It's an alternative, but not a good one. You don't know how long to sleep for. select() does. On average a manual poll must sleep for double the required time per attempt, and waste CPU cycles while looping until success. select() doesn't have any of those issues.