static void Main() { var from = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 30001); var destination = new IPEndPoint(IPAddress.Parse("125.39.187.84"), 30000); TcpForwarderSlim Listener = new TcpForwarderSlim(); Console.WriteLine("Server listening on port 30001. Press enter to exit."); Listener.Start(from, destination); Console.ReadLine(); }
public void Start(IPEndPoint local, IPEndPoint remote) { _mainSocket.Bind(local); _mainSocket.Listen(10); while (true) { var source = _mainSocket.Accept(); var destination = new TcpForwarderSlim(); var state = new State(source, destination._mainSocket); destination.Connect(remote, source); source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state); } }
public static void Main(string[] args) { var ipAddress = "10.208.162.96"; var ipAddress2 = "10.208.162.110"; var port_in = 3333; var port_out = 3333; var tcpForwarder = new TcpForwarderSlim(); tcpForwarder.Start( new IPEndPoint(IPAddress.Parse(ipAddress), port_in), new IPEndPoint(IPAddress.Parse(ipAddress2), port_out)); }
public MainWindow() { InitializeComponent(); TcpForwarderSlim forwarderSlim = new TcpForwarderSlim(); TcpForwarderSlim.SyncSocket = SyncSockets; TcpForwarderSlim.UpdateRequest = UpdateRequest; new Thread(() => { forwarderSlim.Start(new IPEndPoint(IPAddress.Any, 8090), new IPEndPoint(IPAddress.Parse("10.30.138.135"), 8090)); }).Start(); }
public void Start(IPEndPoint local, IPEndPoint remote) { try { _mainSocket.Bind(local); _mainSocket.Listen(10); } catch (SocketException SE) { string error = "An error occured while connecting [" + SE.Message + "]\n"; throw new Exception(error); } while (true) { var source = _mainSocket.Accept(); var destination = new TcpForwarderSlim(); var state = new State(source, destination._mainSocket); destination.Connect(remote, source); source.BeginReceive(state.Buffer, 0, state.Buffer.Length, 0, OnDataReceive, state); } }