Socket Protocol Fundamentals

后端 未结 5 924
温柔的废话
温柔的废话 2020-12-16 18:37

Recently, while reading a Socket Programming HOWTO the following section jumped out at me:

But if you plan to reuse your socket for further transfers,

5条回答
  •  無奈伤痛
    2020-12-16 19:11

    These are indeed our choices with TCP. HTTP, for example, uses a mix of second, third, and forth option (double new-line ends request/response headers, which might contain the Content-Length header or indicate chunked encoding, or it might say Connection: close and not give you the content length but expect you to rely on reading EOF.)

    I prefer the third option, i.e. self-describing messages, though fixed-length is plain easy when suitable.

提交回复
热议问题