1 57 58 package org.apache.soap.util.net; 59 60 import java.net.*; 61 import java.io.*; 62 63 70 public class TcpTunnel { 71 public static void main (String args[]) throws IOException { 72 if (args.length != 3) { 73 System.err.println ("Usage: java TcpTunnel listenport tunnelhost tunnelport"); 74 System.exit (1); 75 } 76 77 int listenport = Integer.parseInt (args[0]); 78 String tunnelhost = args[1]; 79 int tunnelport = Integer.parseInt (args[2]); 80 81 System.out.println ("TcpTunnel: ready to rock and roll on port " + 82 listenport); 83 84 ServerSocket ss = new ServerSocket (listenport); 85 while (true) { 86 Socket sc = ss.accept (); 88 89 Socket st = new Socket (tunnelhost, tunnelport); 91 92 System.out.println ("TcpTunnel: tunnelling port " + listenport + 93 " to port " + tunnelport + " on host " + 94 tunnelhost); 95 96 new Relay (sc.getInputStream(), st.getOutputStream(), null).start (); 98 new Relay (st.getInputStream(), sc.getOutputStream(), null).start (); 99 100 } 102 } 103 } 104 | Popular Tags |