Here is an example of ReceiveCallback from MSDN.
int bytesRecv = clientSocket.EndReceive(result); if (bytesRecv > 0) { clientSocket.BeginReceive(ci.Buffer, 0, ci.Buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), ci); } else { Console.WriteLine("Response"); } Suppose the client-side buffer size is 16 bytes. If I send from the server side, let's say 32 bytes, then the callback executes only two times by accepting 16 + 16 bytes. In this regard, the check bytesRecv = 0 does not work, and Console.WriteLine("") does not work, because The third time the callback does not start. What am I doing wrong?