예제 #1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            m_name       = new NameWindow();
            m_name.Owner = this;
            if (m_name.ShowDialog() == true)
            {
                name = m_name.name;
                label_welcome.Content = "Welcome " + name + " !";
            }
            m_regclient.name = name;

            int index   = -1;
            var address = Dns.GetHostEntry(host);

            for (int i = 0; i < address.AddressList.Length; i++)
            {
                if (address.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                {
                    index = i;
                    break;
                }
            }
            if (index == -1)
            {
                MessageBox.Show("无法从" + host + "获得IP地址.");
                return;
            }

            endpoint = new IPEndPoint(address.AddressList[index], port);
            socket.Connect(endpoint);

            m_regclient.StartFlap(socket, endpoint);
            recv_thread.Start(Thread.CurrentThread);
        }
예제 #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            m_name = new NameWindow();
            m_name.Owner = this;
            if (m_name.ShowDialog() == true)
            {
                name = m_name.name;
                label_welcome.Content = "Welcome " + name + " !";
            }
            m_regclient.name = name;

            int index = -1;
            var address = Dns.GetHostEntry(host);
            for (int i = 0; i < address.AddressList.Length; i++)
            {
                if (address.AddressList[i].AddressFamily == AddressFamily.InterNetwork)
                {
                    index = i;
                    break;
                }
            }
            if (index == -1)
            {
                MessageBox.Show("无法从" + host + "获得IP地址.");
                return;
            }

            endpoint = new IPEndPoint(address.AddressList[index], port);
            socket.Connect(endpoint);

            m_regclient.StartFlap(socket, endpoint);
            recv_thread.Start(Thread.CurrentThread);
        }