Skip to main content
replaced https://tools.ietf.org/html/rfc with https://www.rfc-editor.org/rfc/rfc
Source Link

TCP is a stream-oriented transmission protocol; it only cares about getting bytes in the right order from one host to another, it doesn’t care about the content of those bytes or any message they might form. Once a connection is established, either end of the connection can send bytes to the other.

To give meaning to a message you need to agree on a protocol on top of TCP. It’s this protocol which determines what messages should be sent, and how to interpret received messages; this includes determining when a message is complete. For example, in HTTP, if the “Content-Length” header is present, the receiver can use that to figure out whether it has received all the data; if it isn’t, other methods are used (see the RFCthe RFC for details), up to simply waiting for the server to close the connection (which in some way is using TCP to determine message length, albeit in a rather expensive fashion).

If you want to send individual messages using a message-oriented transport protocol, you could use UDP or SCTP instead of TCP.

TCP is a stream-oriented transmission protocol; it only cares about getting bytes in the right order from one host to another, it doesn’t care about the content of those bytes or any message they might form. Once a connection is established, either end of the connection can send bytes to the other.

To give meaning to a message you need to agree on a protocol on top of TCP. It’s this protocol which determines what messages should be sent, and how to interpret received messages; this includes determining when a message is complete. For example, in HTTP, if the “Content-Length” header is present, the receiver can use that to figure out whether it has received all the data; if it isn’t, other methods are used (see the RFC for details), up to simply waiting for the server to close the connection (which in some way is using TCP to determine message length, albeit in a rather expensive fashion).

If you want to send individual messages using a message-oriented transport protocol, you could use UDP or SCTP instead of TCP.

TCP is a stream-oriented transmission protocol; it only cares about getting bytes in the right order from one host to another, it doesn’t care about the content of those bytes or any message they might form. Once a connection is established, either end of the connection can send bytes to the other.

To give meaning to a message you need to agree on a protocol on top of TCP. It’s this protocol which determines what messages should be sent, and how to interpret received messages; this includes determining when a message is complete. For example, in HTTP, if the “Content-Length” header is present, the receiver can use that to figure out whether it has received all the data; if it isn’t, other methods are used (see the RFC for details), up to simply waiting for the server to close the connection (which in some way is using TCP to determine message length, albeit in a rather expensive fashion).

If you want to send individual messages using a message-oriented transport protocol, you could use UDP or SCTP instead of TCP.

Source Link
Stephen Kitt
  • 481.5k
  • 60
  • 1.2k
  • 1.4k

TCP is a stream-oriented transmission protocol; it only cares about getting bytes in the right order from one host to another, it doesn’t care about the content of those bytes or any message they might form. Once a connection is established, either end of the connection can send bytes to the other.

To give meaning to a message you need to agree on a protocol on top of TCP. It’s this protocol which determines what messages should be sent, and how to interpret received messages; this includes determining when a message is complete. For example, in HTTP, if the “Content-Length” header is present, the receiver can use that to figure out whether it has received all the data; if it isn’t, other methods are used (see the RFC for details), up to simply waiting for the server to close the connection (which in some way is using TCP to determine message length, albeit in a rather expensive fashion).

If you want to send individual messages using a message-oriented transport protocol, you could use UDP or SCTP instead of TCP.