UDP Timeout concerns

Mar 17, 2008 at 10:14 PM
I appreciate the work you put into this. We were just talking about implementing something like this in-house. You saved us some time! I had one issue come up while using it though. I had a situation where a DNS server didn't exist or wasn't properly set, so the UDP Receive function would hang indefinitely. I changed your code to take in a timeout_ms parameter in the Resolve function, and I set the underlying socket receive timeout to use it so everything could dispose properly when it timed out. Works like a charm now! Thanks!

Here's a snippet

UdpClient udpClient = new UdpClient();
udpClient.Send(bDnsQuery, bDnsQuery.Length);

udpClient.Client.ReceiveTimeout = timeout_ms; //added socket timeout here.
recvBytes = udpClient.Receive(ref ipep);

Apr 5, 2008 at 8:27 PM
Really! I expected there would be a default timeout of some sort (not infinite!)....thanks for the info on adjusting it on the underlying socket! I'll adjust the code here accordingly.
Apr 6, 2008 at 2:27 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 7, 2008 at 4:38 PM
I got the same problem with infinite timeout when server is not responding. I use downloaded library. Should I get source code and recompile with above patch or there will be a new precompiled version of library?
Aug 7, 2008 at 9:33 PM

As of right now, there has not been a new release created with that fix in it. You'll have to download the source and recompile.
Aug 8, 2008 at 10:50 AM
Ok, thanks. I'll done that (downloaded source, open project with Visual Studio 2008 (why so?)) added 3ms timout and and everyting is ok now. Thanks so much for your work.
Aug 20, 2008 at 9:36 PM
no problem!  glad you found it useful.