You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Socket.SendTo/ReceiveFrom crash when send/receive timeouts are set #1
I noticed a crash when using SendTo and ReceiveFrom with sockets that have SendTimeout or ReceiveTimeout values set. As an example, the following code throws an ArgumentOutOfRange exception:
// Wait for DHCPwhile(IPAddress.GetDefaultLocalAddress()==IPAddress.Any)Thread.Sleep(50);// Set up a sample IP endpointIPAddressip=Dns.GetHostEntry("time-a.nist.gov").AddressList[0];EndPointremoteEndPoint=newIPEndPoint(ip,123);// Set up a send/receive buffer with sample databyte[]buffer=newbyte[48];buffer[0]=0x1B;using(Socketsocket=newSocket(AddressFamily.InterNetwork,SocketType.Dgram,ProtocolType.Udp)){socket.SendTimeout=1000;socket.ReceiveTimeout=1000;socket.SendTo(buffer,remoteEndPoint);socket.ReceiveFrom(buffer,refremoteEndPoint);}
If you comment out the SendTimeout line, the call to SendTo completes successfully. Similarly, commenting out the ReceiveTimeout line makes the ReceiveFrom call complete successfully.
This issue does not appear to be present when using the Send/Receive methods.
Please let me know if you need any more information. Thanks!
Activity