示例#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);
                    //manejar la informacion de la red
                    ServerHandleNetworkData.manejadorInfoDeRed(index, databuffer);
                    socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), socket);
                }
            }
            catch (Exception e)
            {
                CloseClient(index);
                Console.WriteLine(e);
            }
        }
示例#2
0
 static void Main(string[] args)
 {
     ServerHandleNetworkData.IniciadorPaquetesRed();
     ServerTCP.SetupServer();
     Console.ReadLine();
 }