udp 10054

udp 收发数据时出现10054的异常,解决方法如下:

 

           _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            uint IOC_IN = 0x80000000;
            uint IOC_VENDOR = 0x18000000;
            uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
            _socket.IOControl((int)SIO_UDP_CONNRESET, new byte[] { Convert.ToByte(false) }, null);

            IPEndPoint local = new IPEndPoint(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0], 8087);
            _socket.Bind(local);

红色字体部分为重点

posted on 2008-11-12 20:31  青竹园主  阅读(461)  评论(0编辑  收藏  举报