예제 #1
0
        public bool Connect(string host, int port)
        {
            hs      = new HostStruct();
            hs.host = host;
            hs.port = port;
            state   = SocketState.HANDSHAKING;

            try
            {
                IPEndPoint ipEnd  = new IPEndPoint(proxy.ip, proxy.port);
                Socket     client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                clientSocket = client;
                client.BeginConnect(ipEnd, new AsyncCallback(ConnectCallback), hs);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return(isConnected);
        }
예제 #2
0
        public bool Connect(string host, int port)
        {
            hs = new HostStruct();
            hs.host = host;
            hs.port = port;
            state = SocketState.HANDSHAKING;

            try
            {
                IPEndPoint ipEnd = new IPEndPoint(proxy.ip, proxy.port);
                Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                clientSocket = client;
                client.BeginConnect(ipEnd, new AsyncCallback(ConnectCallback), hs);
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            return isConnected;
        }