public TcpServerEventArgs(ConnectionState cs) { ConnectionState = cs; }
/// <summary> /// Accepts the connection and invokes any Connected event handlers. /// </summary> /// <param name="res"></param> protected void AcceptConnection(IAsyncResult res) { Socket connection; // Make sure listener doesn't go null on us. lock (this) { connection = listener.EndAccept(res); listener.BeginAccept(AcceptConnection, null); } // Close the connection if there are no handlers to accept it! if (Connected == null) { connection.Close(); } else { ConnectionState cs = new ConnectionState(connection, this); OnConnected(new TcpServerEventArgs(cs)); } }