简体   繁体   中英

tcp socket data out of order?

When sending data over a socket, I read that the individual messages can be fragemented, so that I receive differently sized packages then I sent. That's ok and easy to deal with.

However, I'm a bit unsure if these messages could also arrive out of order? Is a TCP socket like a stream, so that the order is garuanteed? I tried to find some information on this via google, but so far I haven't found anything. If packages can arrive out of order I also wonder how to deal with it, if I can not rely on a particular size or order?

Your application will get ordered data stream.

Let kernel do the stuff about packet loss, ordering, etc. - its out of your bussiness.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM