日期:2014-05-20  浏览次数:20683 次

用C#写了一个图形化Ping,但执行后输入Ip点Ping按钮后就没有任何反映,好像程序死了一样,急急急!!
我的图形是这样的:Ip是从textBox1中输入,在点击IP按钮,结果在listBox1中输出
这是Ip按钮的代码:
private   void   button1_Click(object   sender,   EventArgs   e)
                {
                        listBox1.Items.Clear();
                       
                        string     Hostclicent   =textBox1.Text;
                       
                        int   K;
                        for   (K   =   0;   K   <   3;   K++)
                        {
                                Socket   Socket   =   new   Socket(AddressFamily.InterNetwork,   SocketType.Raw,   ProtocolType.Icmp);
                                IPHostEntry   Hostinfo;

                                try
                                {
                                        Hostinfo   =   Dns.GetHostEntry(Hostclicent);
                                     

                                }
                                catch   (Exception)
                                {
                                        listBox1.Items.Add( "没有发现此主机! ");
                                        return;
                                }


                                EndPoint   Hostpoint   =   (EndPoint   )new   IPEndPoint(Hostinfo.AddressList[0],   0);
                             
                                IPHostEntry   Clientinfo;
                                try
                                {