4 ms·
I'd like to try an interface that provides all traffic on a given port, regardless of the IP address on the other end, via a single file descriptor. One reason
by tzs 10y ago
I'd like to try an interface that provides all traffic on a given port, regardless of the IP address on the other end, via a single file descriptor.
One reasonable way to design a server is to queue all requests onto a single queue, and then have multiple worker threads that take requests from the queue and process them.
When requests arrive from the outside, they are coming in multiplexed onto one data stream (assuming one network cable). It seems wasteful to have the kernel demultiplex these into separate streams (one per client), just for your application to remultiplex them when it puts them onto its queue.
If the server application is handling all traffic for the port, let it handle the demultiplexing.
TCP flow control might get a bit tricky, because I think you'd want to still handle that in the kernel.
With this kind of system your server application would have one file descriptor for reading network data, and it could have a single thread dedicated to reading that in blocking mode.
- nostrademons 10y agoHow would you handle requests that span more than one packet? The point of the "socket" abstraction is so that the kernel can make the arrival of packets - which may appear out-of-order, or not at all - seem like a continuous stream of data to the application. Get rid of the multiplexing, and you also get rid of the socket receive buffer. The application basically needs to implement a TCP layer in userspace. BTW, UDP sockets provide exactly the abstraction you're looking for: the sending IP address is filled in along with the data, and there's no socket to wait on.
- daurnimator 10y ago> I'd like to try an interface that provides all traffic on a given port, regardless of the IP address on the other end, via a single file descriptor. Like NETLINK_NETFILTER?