示例#1
0
        void AsyncConnectCallback(IAsyncResult ar)
        {
            try
            {
                // Complete the connection.
                _socket.EndConnect(ar);

                //handler.ConnectCallback((IPEndPoint)socket.RemoteEndPoint);
                handler.ConnectCallback((IPEndPoint)_socket.LocalEndPoint);

                //Send(String.Format("VERSION {1}", this.Version));
                ReadNext();

                // UserUpdateLoop and PingLoop also have to start here.
            }
            catch (Exception e)
            {
                handler.Log(e.ToString());
                Disconnect();
            }
        }
示例#2
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());
            }
        }