I have a simple (?) C# thread that listens on a UDP socket and returns
basic information to whoever asks for it.
I have a not-easily-repeatable error (although it recurs regularly, but
not predictably), where I get an exception because I take what I received,
process it, but when I get to the Send method, it turns out that the
IPEndpoint I got from Receive has a null (0.0.0.0) IP address.
This is for .NET 3.5.
The documentation does NOT mention this as an option, and only says that it
may throw a SocketException, which I catch, but have not seen!
The code does not "do" anything with the IPEndPoint from the time the
data is received until it sends the response.
Has anyone seen anything like this?
Or does anyone have any ideas about what would cause this?
I am running tests to try and capture it right now...
Tuesday 08/09/11 update:
I added the following code after the call to UDPClient.Receive(ref receivePoint):
if (receivePoint.Address.Equals(IPAddress.Parse("0.0.0.0")))
{
log.ErrorOut("CollectorMonitor", "Got NULL IP Address from Receive()", Constants.ERROR_RECVD_NULL_IPADDRESS);
continue;
}
I still got the exception, but it did NOT catch the condition above! However, while the
code was in the debugger, when I did a Quick watch on the condition, it showed as true!
Now, this is a threaded application, and the other threads use TCPClient. Could there be
some type of weird interaction going on there?
Thanks,
Mitch