Beispiel #1
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            Socket socket = (Socket)ar.AsyncState;

            try
            {
                int received = socket.EndReceive(ar);
                if (received <= 0)
                {
                    CloseClient(index);
                }
                else
                {
                    byte[] dataBuffer = new byte[received];
                    Array.Copy(buffer, dataBuffer, received);

                    //HandleNetworkInformation
                    ServerHandleNetworkData.HandleNetworkInformation(index, dataBuffer);
                    socket.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), socket);
                }
            }
            catch { CloseClient(index); }
        }
Beispiel #2
0
 static void Main(string[] args)
 {
     ServerHandleNetworkData.InitializeNetworkPackages();
     ServerTCP.SetupServer();
     Console.ReadKey();
 }