Programmer2030
Programmer2030

Reputation: 39

Can TCP transmit multiple application layer messages concurrently withing the same TCP connection?

I’m reading the article how TCP breaks application message into smaller parts (TCP segments) and use sequence and acknowledge numbers for interacting. In the article there is a example how is transmitting one application layer message within one TCP connection. So, I have a question. Can TCP transmit multiple application layer messages concurrently withing the same TCP connection.

In other words:

  1. Creating TCP connection between client and server.
  2. Client breaks message1 from application layer into TCP segments and start sending them
  3. Client breaks message2 from application layer into TCP segments and start sending them
  4. Client breaks message3 from application layer into TCP segments and start sending them

Step 2,3,4 are going in parallel withing the same TCP connection.

  1. Server receives segments from message1, message2, message3 and send responses in parallel.

Is this possible somehow in TCP? Or we can transmit messages only consequently within the same TCP connection. I’m interested in TCP protocol itself, it doesn’t matter what tricks are used in application layer like multiplexing.

Upvotes: 0

Views: 378

Answers (1)

Steffen Ullrich
Steffen Ullrich

Reputation: 123260

I’m reading the article how TCP breaks application message into smaller parts

TCP does not break application messages into smaller parts because there is no concept of an "application message" at the TCP level. From the perspective of TCP there is only a byte stream with no inherent semantics. Arbitrary splitting but also merging can be done at the byte stream for optimal transport. All what matters is that the bytes are delivered reliably, in order and without duplicates to the peer.

Any application which relies on TCP somehow maintaining message boundaries is broken - and StackOverflow is full of such examples and the problems caused by this.

Can TCP transmit multiple application layer messages concurrently withing the same TCP connection.

It is up to the application protocol and not TCP to implement such a behavior. For example HTTP/1 has only a concept of one message after the other - which clear protocol defined boundaries where messages start and end in the byte stream. In HTTP/2 messages can overlap though because HTTP/2 implements some kind of multiplexing inside the application protocol. But again - all of this is defined and implemented at the application layer and not at the transport layer (TCP).

Upvotes: 1

Related Questions