As a network client I would like to follow the input from two TCP connections. Both servers send a few packets per second. Each packet is small in size when compared to the available bandwidth.
Ideally we'd like to read both sockets from a single thread for the best latency. My initial plan was to use FIONREAD from ioctl(2) on each connection in a loop, and only read when data is available. Are there other options? CPU consumption is less relevant than low latency.
select()and non-blocking mode.poll(if you are on a Posix system).select()with blocking-mode sockets.accept()can return null.read()andwrite()can return -1/EAGAIN/EWOULDBLOCK. How many do you need?