internal PortWatcher(Session session, String address, int lport, String host, int rport, ITcpListenerFactory factory) { this.session = session; this.lport = lport; this.host = host; this.rport = rport; try { boundaddress = Dns.GetHostEntry(address).AddressList[0]; #if false ss = (factory == null) ? new JTcpListener(lport, 0, boundaddress) : factory.createServerSocket(lport, 0, boundaddress); #else if (factory == null) { ss = new TcpListener(boundaddress, lport); ss.Start(); } else { ss = factory.createServerSocket(lport, 0, boundaddress); } #endif } catch (Exception e) { Console.WriteLine(e); throw new SshClientException("PortForwardingL: local port " + address + ":" + lport + " cannot be bound."); } }
public Server( ITcpListenerFactory tcpListenerFactory, ITcpClientHandler tcpClientConnectedEventHandler) { _tcpListenerFactory = tcpListenerFactory ?? throw new ArgumentNullException(nameof(tcpListenerFactory)); _tcpClientConnectedEventHandler = tcpClientConnectedEventHandler ?? throw new ArgumentNullException(nameof(tcpClientConnectedEventHandler)); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public TcpMessageSink(ITcpListenerFactory tcpListenerFactory, MessageEventDispatcher messageEventDispatcher, IMessageSerializerFactory messageSerializerFactory) { this._messageEventDispatcher = messageEventDispatcher; this._messageSerializerFactory = messageSerializerFactory; this._tcpListener = tcpListenerFactory.CreateListener(); this._connections = new List<TcpMessageSinkClientConnection>(); }
internal static PortWatcher addPort(Session session, String address, int lport, String host, int rport, ITcpListenerFactory ssf) { if (getPort(session, address, lport) != null) { throw new SshClientException("PortForwardingL: local port " + address + ":" + lport + " is already registered."); } PortWatcher pw = new PortWatcher(session, address, lport, host, rport, ssf); pool.Add(pw); return(pw); }