4 ms·
I have always had this sort of nagging feeling about the way BSD sockets works: it really is a bit strange that the reading and writing operations are effective
by jchw 3y ago
I have always had this sort of nagging feeling about the way BSD sockets works: it really is a bit strange that the reading and writing operations are effectively entirely separate. When you write to most FDs, the inverse operation is reading; but sockets don't work that way, reading and writing are effectively working on two different streams!
The insight that a TCP connection is basically equivalent to a pipe is a pretty good demonstration of how this could have been better.
As another related example, imagine if the same had been done for standard I/O. What if instead of having separate file descriptors, all of the standard I/O happened through one file descriptor? Imagine how much more painful everything would be.
Unfortunately, this is now pretty much how a lot of stuff works, but it did not really have to go this way.