News for hackers. Stuff that matters.
Re:Why is my tcp not reliable? (2009) by Animats on Saturday April 01, 2017 @11:16PM (#14015564)
It's a Berkeleyism. It's not TCP, it's old Berkeley Sockets semantics. The TCP protocol supports half-close. When you're done writing you're supposed to close your write side, then read until you get an EOF. But the Berkeley people didn't support that.

Linux does support it, with the "shutdown(2)" call.[1] When you're done writing, you shut down the write side. The other end sees an EOF, and they close. You read to EOF, and you close. If shutdown and close return normally, all data was delivered. Assuming this was implemented right.

[1] http://man7.org/linux/man-pages/man2/shutdown.2.html

Re:Why is my tcp not reliable? (2009) by cperciva on Sunday April 02, 2017 @01:55AM (#14016013)
It's a Berkeleyism. It's not TCP, it's old Berkeley Sockets semantics. [...] Linux does support it, with the "shutdown(2)" call.

The shutdown(2) system call was added to BSD on January 8th, 1983: https://svnweb.freebsd.org/csrg?view=revision&revision=10208

So... Berkeley Sockets supported this a bit more than 8 years before Linux even existed. This is totally not a Berkeley Sockets problem.

Re:Why is my tcp not reliable? (2009) by ahubert on Sunday April 02, 2017 @07:43AM (#14016802)
What you describe (the shutdown technique) is exactly what my linked blogpost describes, by the way. If this is the fault of BSD, or the sockets API definition is indeed an interesting question. Is RFC 1122 TCP/IP or a BSD document? Anyhow, use the shutdown technique or even better, explicit length or chunked.