Esempio n. 1
0
        public void Connect(IPEndPoint remoteEP)
        {
            if (client != null)
            {
                Disconnect();
            }

            try
            {
                client = new UdpClient(_localPort);
                //client.Connect(remoteEP);
                remoteEndPoint = remoteEP;
                handler.ConnectCallback((IPEndPoint)client.Client.LocalEndPoint);

                ReadNext();
            }
            catch (Exception ex)
            {
                handler.Log(ex.ToString());
            }
        }
Esempio n. 2
0
        public void Connect(IPEndPoint remoteEP)
        {
            try
            {
                // Create a TCP/IP socket.
                _socket = new Socket(
                    AddressFamily.InterNetwork,
                    SocketType.Stream,
                    ProtocolType.Tcp);

                // Connect to the remote endpoint.
                _socket.BeginConnect(
                    remoteEP,
                    ConnectCallback,
                    _socket);

                //connectDone.WaitOne();
            }
            catch (Exception e)
            {
                handler.Log(e.ToString());
                Disconnect();
            }
        }