Пример #1
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            var socket = (Socket)ar.AsyncState;

            try
            {
                var received = socket.EndReceive(ar);
                if (received <= 0)
                {
                    CloseClient(Index);
                }
                else
                {
                    var dataBuffer = new byte[received];
                    Array.Copy(_buffer, dataBuffer, received);
                    ServerHandleNetworkData.HandleNetworkInformation(Index, dataBuffer);
                    socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, ReceiveCallback, ClientSocket);
                }
            }
            catch (Exception)
            {
                CloseClient(Index);
            }
        }
Пример #2
0
 static void Main(string[] args)
 {
     ServerHandleNetworkData.InitializeNetworkPackages();
     ServerTCP.SetupServer();
     Console.ReadLine();
 }