cunixtcpclientlow-latencysingle-threaded

Read multiple sockets from single thread [low-latency]


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.


Solution

  • You want to use one of these I/O multiplexing primitives: