protected void start() throws IOException { socket.setSendBufferSize(getLocalMaxPacketSize()); socket.setReceiveBufferSize(getRemoteMaxPacketSize()); final Event<IOException> soc2chan = new StreamCopier(socket.getInputStream(), getOutputStream(), loggerFactory) .bufSize(getRemoteMaxPacketSize()) .spawnDaemon("soc2chan"); final Event<IOException> chan2soc = new StreamCopier(getInputStream(), socket.getOutputStream(), loggerFactory) .bufSize(getLocalMaxPacketSize()) .spawnDaemon("chan2soc"); SocketStreamCopyMonitor.monitor(5, TimeUnit.SECONDS, soc2chan, chan2soc, this, socket); }
/** * Start listening for incoming connections and forward to remote host as a channel. * * @throws IOException */ public void listen() throws IOException { log.info("Listening on {}", serverSocket.getLocalSocketAddress()); while (!Thread.currentThread().isInterrupted()) { final Socket socket = serverSocket.accept(); log.debug("Got connection from {}", socket.getRemoteSocketAddress()); openChannel(socket).start(); } log.debug("Interrupted!"); }
private void startChannel(Socket socket) throws IOException { DirectTCPIPChannel chan = new DirectTCPIPChannel(conn, socket, parameters); try { chan.open(); chan.start(); } catch (IOException e) { IOUtils.closeQuietly(chan, asCloseable(socket)); throw e; } }
protected void start() throws IOException { socket.setSendBufferSize(getLocalMaxPacketSize()); socket.setReceiveBufferSize(getRemoteMaxPacketSize()); final Event<IOException> soc2chan = new StreamCopier(socket.getInputStream(), getOutputStream()) .bufSize(getRemoteMaxPacketSize()) .spawnDaemon("soc2chan"); final Event<IOException> chan2soc = new StreamCopier(getInputStream(), socket.getOutputStream()) .bufSize(getLocalMaxPacketSize()) .spawnDaemon("chan2soc"); SocketStreamCopyMonitor.monitor(5, TimeUnit.SECONDS, soc2chan, chan2soc, this, socket); }
protected void start() throws IOException { socket.setSendBufferSize(getLocalMaxPacketSize()); socket.setReceiveBufferSize(getRemoteMaxPacketSize()); final Event<IOException> soc2chan = new StreamCopier(socket.getInputStream(), getOutputStream(), loggerFactory) .bufSize(getRemoteMaxPacketSize()) .spawnDaemon("soc2chan"); final Event<IOException> chan2soc = new StreamCopier(getInputStream(), socket.getOutputStream(), loggerFactory) .bufSize(getLocalMaxPacketSize()) .spawnDaemon("chan2soc"); SocketStreamCopyMonitor.monitor(5, TimeUnit.SECONDS, soc2chan, chan2soc, this, socket); }
protected DirectTCPIPChannel openChannel(Socket socket) throws TransportException, ConnectionException { final DirectTCPIPChannel chan = new DirectTCPIPChannel(conn, socket, parameters); chan.open(); return chan; }
private void startChannel(Socket socket) throws IOException { DirectTCPIPChannel chan = new DirectTCPIPChannel(conn, socket, parameters); try { chan.open(); chan.start(); } catch (IOException e) { IOUtils.closeQuietly(chan, asCloseable(socket)); throw e; } }