I'm building client server application over TCP. The order of the arrival of the messages from the client to the server is important. Does TCP assure me that all the messages (packets) that I will send from the client to server will arrived at the same order they had been send?

Thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

No, packets can arrive out of order. They are reordered, but I am not sure at what layer.
packets can also be dropped, requiring a resend
Typically the re-ordering of packets is done at a layer that won't make a difference to an application. By the time it hits the application, the packets should be back in order. What is your application? If it is voice or video, I would be more concerned about jitter than packet order. (jitter is the delta in the lag)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

> No, packets can arrive out of order.

Yes, IP-packets can arrive out of order.

> They are reordered, but I am not sure at what layer.

I am sure that it is the TCP (Transmission Control Protocol) running _OVER_ the IP (Internet Protocol) --
read it as "Tea See Pea over Eye Pea" -- which
re-requests "missing" packets, and orders the IP-packets
andyalderSaggar maker's framemakerCommented:
You are right, it's TCP (layer 4) that re-orders the packets and requests re-transmission of any missing packets (it knows that a packet is missed because of sequence numbers in the session).

If on the other hand you were to use UDP then you would have to build the reliability into your application. TCP is less efficient but it's reliable.
As long as you are using tcp, and not udp, al your packets will arrive..
tcp wiats for an aknowledgement, before he sends the next packet..
Udp, does not, thats why it faster, but less relyable

Erik Kruijswijk
The answer is simply YES. Providing that your application is using TCP protocol. In that case you don't have to be woried about the mesages order. Your distination host will receive it in the same order your source host is sending with error recovery and this is one of the TCP fruits if we compare it with UDP.
I Hope that this will satisfy your needs.
> TCP waits for an acknowledgement before sending the next packet..

Not always true -- a "windowing" technique is often used.
TCP will send, say, five packets, and then wait to receive
the acknowledgment of the _FIRST_ packet before sending
the _SIXTH_ packet.  
Obviously, this increases "throughput" of the connection.
If you use TCP in your application all of the stuff mentioned above will be carried out for you by NIC/NIC Driver/ Opperating system and WINSOCK.

You will therefore gain a error corrected, in order data pipe between your client and server without needing to get involved in the underlying layers.

A word of warning though, if you mishandle using tcp you can cause issues with the underlyiong layers. I have seen some socket dlls do pretty weird things on the network if for example you put some data in the send buffer and then cxlose the socket before waiting for the send buffer to empty.
Asta CuTechnical consultant & graphic designCommented:

This question remains open today; perhaps just overlooked this or it just got lost in the volumes.  If you've been helped to resolve this, please accept the comment which helped you as the accepted answer to then grade and close so that others may benefit from this information as it migrates to our PAQ Database.  If more is needed, please update here via comments so that you can achieve your goal.

Your attention to finalizing this is very much appreciated.


These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days. Please note that the recommended minimum for an "Easy" question is 50 points.

EXPERTS: Please leave your thoughts on this question here.


Community Support Moderator
Experts Exchange
Admin notified of user neglect. Force/accepted by

Community Support Moderator
Experts Exchange
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Email Protocols

From novice to tech pro — start learning today.