3 ms·
> Splitting the socket fully into two separate file handles would mean that users could close one of them without realizing it, and thus be able to write a new
by jmalicki 3y ago
> Splitting the socket fully into two separate file handles would mean that users could close one of them without realizing it, and thus be able to write a new sort of bug where they would be able to ask stack overflow "I'm able to read from my socket but not write from it, what gives?"
shutdown(sockfd, 1)
gives you "I'm able to read from my socket but not write from it, what gives?"
The real bugs with TCP come from "why am I not able to download the file because the server did close(sockfd) rather than shutdown(sockfd, 1), and my TCP stack ACK'd, causing the server to RST, causing my machine to give me an error before I read all of the data".
This is already waaaay harder than the counterfactual you're imagining, and the bugs are here, today.