How to implement tcp proxy using vert.x verticle?

946 views
Skip to first unread message

Jeong-Hoon Baek

unread,
Oct 6, 2013, 1:56:03 PM10/6/13
to ve...@googlegroups.com
I want the server like this twisted proxy server.

So I wrote proxy server using verticle, But it's not worked. What's wrong?
I assume that Pump related code has some problem, but I don't know right solution.

    import org.vertx.java.core.AsyncResult;
    import org.vertx.java.core.Handler;
    import org.vertx.java.core.net.NetSocket;
    import org.vertx.java.core.net.NetClient;
    import org.vertx.java.platform.Verticle;
    import org.vertx.java.core.streams.Pump;

    public class ProxyServer extends Verticle {

     public void start()  {

      vertx.createNetServer().connectHandler(new Handler<NetSocket>() {
        public void handle(final NetSocket socket) {
            NetClient client = vertx.createNetClient();
            client.connect(9999, "192.168.0.254", new Handler<AsyncResult<NetSocket>>() {
                public void handle(final AsyncResult<NetSocket> asyncSocket) {
                    NetSocket cSocket = asyncSocket.result();
                    Pump.createPump(cSocket, socket).start();
                    Pump.createPump(socket, cSocket).start();
                }
            });
        }
      }).listen(9999);
     }
    }

Norman Maurer

unread,
Oct 6, 2013, 2:06:54 PM10/6/13
to ve...@googlegroups.com
Check out the vertx-example repos which somes with an example of a proxy written with vert.x 



2013/10/6 Jeong-Hoon Baek <coa...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages