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); TCPHandler.HandleNetworkInformation(index, databuffer); socket.BeginReceive(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(ReceiveCallback), socket); } } catch { CloseClient(index); } }
static void Main(string[] args) { TCPHandler.InitializeTCPHandler(); TCP.SetupServer(); Console.ReadLine(); }