News for hackers. Stuff that matters.
Re:Each socket should have two file descriptors by tptacek on Monday July 22, 2013 @12:28AM (#6081755)
He said it creates two pipes, and later that each pipe creates two descriptors.

He never said there was no reason that sockets behaved differently than other descriptors, only that the reasons didn't warrant the broken abstraction.

And finally, I think you missed the place where he claims the abstraction breaks down. He's not complaining that you use "open" to get a file's descriptor and "pipe" to get a pipe's two descriptors, any more than it's weird to get a socket descriptor for "socket". He's saying that once you have the descriptor, the single file descriptor for sockets forces the OS to implement a socket-specific call simply to get a FIN sent properly.

The reality is that sockets could be represented not with integer descriptors but with character arrays or structs and the Unix interface wouldn't be any less incoherent than it is now with accepting descriptors, a select call that works for sockets and not files, setsockopt, shutdown, recv, connected Unix domain sockets, ioctls, and so on and so forth.

There are no comments on this comment yet.