How to manage multiple connections?

How to manage multiple connections?




I have to monitor more than one (fd/connection/stream) at a time. How do
I manage all of them?




Use select() or poll().



Note: select() was introduced in BSD, whereas poll() is an
artifact of SysV STREAMS. As such, there are portability issues; pure
BSD systems may still lack poll(), whereas some older SVR3
systems may not have select(). SVR4 added select(), and
the Posix.1g standard defines both.



select() and poll() essentially do the same thing, just
differently. Both of them examine a set of file descriptors to see if
specific events are pending on any, and then optionally wait for a
specified time for an event to happen.



[Important note: neither select() nor poll() do anything
useful when applied to plain files; they are useful for sockets, pipes,
ptys, ttys & possibly other character devices, but this is
system-dependent.]



There the similarity ends....






Home FAQ