Example #1
0
        // Connects to a server and returns Server TcpClient if sucessful, Called when using in Nonproxy mode.
        public TcpClient ConnectToServer(string ip, int port)
        {
            try
            {
                SetupHandlers();
                Helpers.Cliloc Clilocdata = new Helpers.Cliloc();
                Helpers.Cliloc.LoadStringList("enu");
                var Server = new TcpClient();
                IPAddress IP;
                if (IPAddress.TryParse(ip, out IP))
                    Server.Connect(IP, port);
                else
                Server.Connect(ip, port);

                Thread ServerComThread = new Thread(new ParameterizedThreadStart(HandleServerCom));
                ServerComThread.Start(new ClientServer(null, Server));
                this.Server = Server;
                return Server;
            }
            catch
            {
                return null;
            }
        }
Example #2
0
 //When using as a proxy, Call this method, Starts listening for local client connection, once client connects, sends connect to Server
 public bool StartListeningForClient(int port)
 {
     try
     {
         SetupHandlers();
         Helpers.Cliloc Clilocdata = new Helpers.Cliloc();
         Helpers.Cliloc.LoadStringList("enu");
         tcpListener = new TcpListener(IPAddress.Any, port);
         tcpListener.Start();
         tcpListener.BeginAcceptTcpClient(new AsyncCallback(this.AcceptClientConnection), tcpListener);
         //var client = tcpListener.AcceptTcpClient();
         //AcceptClientConnection(client);
         Logger.Log("Listening for incoming Client connections on: " + IPAddress.Loopback + ":" + port);
         ProxyMode = true;
         return true;
     }
     catch
     {
         return false;
     }
 }