![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Looking at the above KB I expect to get SocketExceptions with WSAECONNRESET during Socket.EndReceiveFrom(). And they do happen often. But sometimes I also get same exception during Socket.BeginReceiveFrom(). Why? |
|
What is the best way to fix this problem? |
#3
| |||
| |||
|
|
Since I found out about the IOControl call with SIO_UDP_CONNRESET the problem is gone (no more silly exceptions that I don't care about with UDP!). I've successfully used that on W2K and XP so far. |
#4
| |||
| |||
|
|
I have tried doing as per Zupancic's suggestion (http://blog.devstone.com/aaron/archi...5/02/20.aspx): // 0x9800000C == 2440136844 (uint) == -174483042 (int) == 0x9800000C const int SIO_UDP_CONNRESET = -174483042; byte[] inValue = new byte[] { 0, 0, 0, 0 }; // == false byte[] outValue = new byte[] { 0, 0, 0, 0 }; // initialize to 0 _socket.IOControl(SIO_UDP_CONNRESET, inValue, outValue); But it does not work for me - it throws a SocketException (An invalid argument was supplied). |
#5
| |||
| |||
|
|
Jonas Hei wrote: Zupancic was just telling us that it is kind of lame to copy and paste code snippets from anywhere without giving them a serious thought first. So after being lame for a few hours (give or take a few more hours), I finally gave some thought to it and luckily managed to solve the problem: instead of // 0x9800000C == 2440136844 (uint) == -174483042 (int) == 0x9800000C we need // 0x9800000C == 2550136844 (uint) == -1744830452 (int) == 0x9800000C so this snippet seems to work: const int SIO_UDP_CONNRESET = -1744830452; byte[] inValue = new byte[] { 0, 0, 0, 0 }; // == false byte[] outValue = new byte[] { 0, 0, 0, 0 }; // initialize to 0 _socket.IOControl(SIO_UDP_CONNRESET, inValue, outValue); |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |