Behavior of writing to TCP socket before reading all data
问题 I've been writing small specific purpose HTTP servers for some applications of mine, and I noticed that, if you write() before you read() all available data, the bytes are not sent properly. For example, after read() ing only the request line ( GET / HTTP/1.1\r\n ) sent by my browser, I write() : HTTP/1.1 200 OK\r\n Connection: close\r\r Content-Type: text/html\r\n \r\n (some HTML stuff) Wireshark capture of this write() : '\n' bytes and Content-Type header are gone! (Wireshark always