Question

I'm working on a MMO game server. I have to understand TCP data send/recv operations (not usage, detail). I want to ask this: If I send a 5kb data from a .net socket client, may server socket handle this data send operation one more time? Namely can 5kb data be received one more operation like 5kb = 1. operation:2kb + 2. operation:3kb?

I want to tell this again; If client sent a data to server, can our server listener's Recv() method pass this data to our handler class at one more time (callback operation)?

Was it helpful?

Solution

You are not guaranteed to get all the data from a single Send() within a single Receive().

The TCP algorithm transparently splits your data into individual packets, and there's no direct API control over how big the packets are, or how data gets split when it's too big for a single packet. See Nagle's algorithm for the gory details of how TCP does this under the hood.

If you want to control exact packet contents and send timing, you should consider the packet based protocol UDP instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top