Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>All remotely modern systems have <code>poll</code>, and it's a greatly superior interface to <code>select</code>/<code>pselect</code> in almost all ways:</p> <ul> <li><code>poll</code> allows more fine-grained detection of status than <code>select</code>.</li> <li><code>poll</code> does not have limits on the max file descriptor you can use (and more importantly, does not have critical vulnerabilities when you fail to check for file descriptors past the <code>FD_SETSIZE</code> limit).</li> </ul> <p>The only disadvantages I can think of to using <code>poll</code> are that:</p> <ul> <li>unlike <code>pselect</code>, <code>poll</code> cannot atomically unmask/mask signals, so you can't use it for waiting for a set of events that includes both file descriptor activity and signals unless you resort to the self-pipe trick.</li> <li><code>poll</code> only has millisecond resolution for the wait timeout, rather than microsecond (<code>select</code>) or nanosecond (<code>pselect</code>).</li> </ul> <p>Certainly portability of <code>poll</code> is not a consideration anymore. Any system old enough to lack <code>poll</code> is full of so many vulnerabilities it should not be connected to a network.</p> <p>In summary, unless you have very special needs (tiny timeout intervals, nasty signal interactions, scaling to millions of persistent connections, etc.) I would simply use <code>poll</code> and be done with it. As others have mentioned, <code>libevent</code> is also an option, but it's not clean/safe code (its use of <code>select</code> actually invokes dangerous UB trying to workaround the limitations of <code>select</code>!) and I find code that uses <code>libevent</code> is generally a lot more unnecessarily complicated than code that simply uses <code>poll</code> directly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload