UDP.Send exception issue / TCP Error 11004 Maybe

Hi,

This hopefully is extremely easy, but here we must have a mental block or something as we are battling a recurring Exception issue in the system Dll on this one line of simple code that sends UDP messages

We only use UDP and no TCP/IP calls

We only recently noticed this exeption as these were not being caught in the Application error handler in the application, but rather in the System.dll.

Each time we send a UDP message we generate this exception and it is a performance hammer as we are sending hmmm one every 20 ms or about 50 a second

Here is the exact Exeception info: -------------------------------

A first chance exception of type 'System.Net.Sockets.SocketException' occured in system.dll

Additional information: The requested name is valid and was found in the databse, but it does not have the correct data being resolved for (end of message! this is all the help provided)

End of Exception Text --------------------------------------------------------

Here is the code that generates the exception.

Note, the error line hits is m_udp.Send call

Start of Code Block-----------------------------------------------------------

Public Sub Send(ByVal remoteIP As String, ByVal remotePort As Integer, ByVal bytData() As Byte)
Try
m_udp.Send(bytData, bytData.Length, remoteIP, remotePort)
Catch ex As Exception
Call ErrorLog("Code Base", "UDPClass", "Send", ex.ToString)
End Try
End Sub

End of Code Block -----------------------------------------------------------------------------

Hopefully, this is something simple and/or an alternative syntax for sending UDP can be easily maybe suggested that doesn't have this problem.

This is in VB 2003, .Net 1.1 SP1 code base

Also, I have done an extensive search and found some various notes on and it seems this error is related TCP Error #11004"XP Pro fix" for some similar issues that adjusts registry keys.

One example:

http://www.communicator.pl/faq_eng13.html

Any help or comments much appreciated - Thanks



Answer this question

UDP.Send exception issue / TCP Error 11004 Maybe

  • Joshd23

    XPDev,

    In v1.1 of the framework, the UdpClient.Send method you are calling uses Dns.GetHostAddresses to attempt to turn the hostname string param into an IPAddress so that ultimately it can call the UdpClient.Send method that takes an IPAddress as a param.

    If the hostname string is not an IP address literal string, e.g., "192.168.0.1", then either the native winsock getaddrinfo or gethostbyname function is called to resolve the hostname. Either of these can potentially get the error WSANO_DATA which corresponds to the string you reported. This error would be turned into a SocketException and thrown. It is not immediately clear to me right now that this exception would be caught internally and not thrown to your application.

    Regardless, the previous post's advice is good. If you are frequently sending a datagram to the same host&port you will save significant cpu cycles by resolving the hostname yourself only once in your app and then using the UdpClient.Send method that takes the resolved IPAddress as a parameter to do the repeated sends. That would avoid doing the resolution of the hostname on every send.



  • Andy Hooper

    This sounds like a DNS error and not a general UDP(or TCP)/IP error. Try resolving the hostname via the static Dns.GetHostByName method and then use and IPEndPoint instead of the hostname with the other UpdClient.Send method. Given the number of UDP datagrams you are sending, this would be a good approach anyway.

    If the error occurrs during DNS name resolution then I bet there are issues with the requested host's DNS server records.

    Hope that helps.


  • emanon

    Larry,

    Thanks, this was very helpful information

    XPDev


  • UDP.Send exception issue / TCP Error 11004 Maybe