@Override public void acceptedClient(PyroClient client) { System.out.println( "acceptedClient[client-thread=" + Thread.currentThread().getName() + ", server-thread=" + client.getServer().selector().networkThread().getName() + "]:" + client); InetSocketAddress src = client.getLocalAddress(); InetSocketAddress dst = null; for (Duo<InetSocketAddress> duo : this.srcToDst) { if (duo.first().equals(src)) { dst = duo.second(); break; } } System.out.println( "Redirecting: " + src.getAddress().getHostAddress() + " => " + ((dst == null) ? "*" : dst.getAddress().getHostAddress())); if (dst == null) { client.dropConnection(); return; } try { // make a connection to the other guy PyroClient otherGuy = client.selector().connect(dst); client.addListener(this); otherGuy.addListener(this); client.attach(otherGuy); otherGuy.attach(client); } catch (IOException exc) { exc.printStackTrace(); } }