日期:2014-05-17  浏览次数:20782 次

我想试一下udp发信息 然后用到Receive方法 每次一运行到哪里都会未响应
        public static String xinxis()
        {
            string sx = null;
            UdpClient udpp = new UdpClient(bdukou);
            udpp.Connect(aip, bdukou);
            try
            {
                IPEndPoint ips = new IPEndPoint(IPAddress.Any, 0);
                // Byte[] shoux=new Byte[100000];

                Byte[] shoux = udpp.Receive(ref ips);//出问题的语句 每次到这里程序就会未响应            
                sx = Encoding.Default.GetString(shoux);

                udpp.Close();
               
            }
            catch (SocketException e)
            {
                MessageBox.Show(e.Message, "提示");
                
            }
            return sx; //int shouxx = udpp.Available;
        }
socket udp连接 Receive方法

------解决方案--------------------