internal void Close1() { if (CanClose != true) { } if (CanClose == true) { Closing(); ActionClose?.Invoke(this); } }
internal TcpProxyConnection(TcpClient clientProxyConnection, ActionClose actionProxyCloseConnection, IPEndPoint serverIPEndPoint) { actionCloseConnection = actionProxyCloseConnection ?? throw new ArgumentNullException(nameof(actionProxyCloseConnection), $"{nameof(actionCloseConnection)} cannot be null");; clientConnection = clientProxyConnection ?? throw new ArgumentNullException(nameof(clientProxyConnection), $"{nameof(clientConnection)} cannot be null"); selectedIPEndPointServer = serverIPEndPoint; try { serverConnection = new TcpClient(selectedIPEndPointServer.Address.ToString(), selectedIPEndPointServer.Port); } catch (SocketException e) { Console.WriteLine($"Socket exception: {e}"); throw e; } NetworkStream clientStream = clientConnection.GetStream(); NetworkStream serverStream = serverConnection.GetStream(); TrafficClientToServer(clientStream, serverStream); TrafficServerToClient(clientStream, serverStream); }