public void Listen(IPEndPoint localEndPoint) { if (_listener != null) { throw new InvalidOperationException("You cannot listen on a Tcp socket twice."); } _listener = new TcpListener(localEndPoint); _listener.Start(); Task.Factory.StartNew(async() => { try { while (true) { var client = new TcpClientSocket(this, await _listener.AcceptTcpClientAsync()); } } catch (InvalidOperationException) { // The listener has not been started with a call to Start. throw; } catch (SocketException ex) { Debug.Write(ex); Close(); } }); }
public TcpSocketNotificationEventArgs(TcpClientSocket socket, int errorCode = 0) { Socket = socket; ErrorCode = errorCode; }
public TcpSocketReceiveEventArgs(TcpClientSocket socket, MessageStream message) { Socket = socket; Stream = message; }