Example #1
0
        private void EndReceiveHeader(IAsyncResult ar)
        {
            var bytes = Socket.EndReceiveHeader(ar, out var error);

            if (bytes == 0 ||
                error != SocketError.Success)
            {
                Socket.Disconnect(false);
                return;
            }

            if (Socket.HeaderComplete)
            {
                Socket.BeginReceivePacket(EndReceivePacket, out error, this);
            }
            else
            {
                Socket.BeginReceiveHeader(EndReceiveHeader, out error, this);
            }
        }