-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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 DHCP
while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any)
Thread.Sleep(50);
// Set up a sample IP endpoint
IPAddress ip = Dns.GetHostEntry("time-a.nist.gov").AddressList[0];
EndPoint remoteEndPoint = new IPEndPoint(ip, 123);
// Set up a send/receive buffer with sample data
byte[] buffer = new byte[48];
buffer[0] = 0x1B;
using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
{
socket.SendTimeout = 1000;
socket.ReceiveTimeout = 1000;
socket.SendTo(buffer, remoteEndPoint);
socket.ReceiveFrom(buffer, ref remoteEndPoint);
}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!
Metadata
Metadata
Assignees
Labels
No labels