J
Jim
Hello,
I'm stuck on a problem with the UdpClient.Receive method. I'm writing an app
that listens on
a multicast address for UDP packets sent from another machine. It uses the
UdpClient.Receive method to block while listening for a packet. When a
packet is received, it will return and allow me to
process the data.
The problem is, if I release/renew my IP address while in the blocking
Receive() call, it will block forever. Even though I successfully
reestablish network connectivity and there are plenty of UDP packets
available, this call never returns. Ideally Receive() should throw a socket
error when I lose network connectivity.
I can always force this call to throw by calling UdpClient.Close() on
another thread, but this would require another thread just to monitor
network connectivity and make the UdpClient throw when it
should. I'd hate to have to add another thread just for that.
Is there a better way to do this?
Thank you,
-Jim
I'm stuck on a problem with the UdpClient.Receive method. I'm writing an app
that listens on
a multicast address for UDP packets sent from another machine. It uses the
UdpClient.Receive method to block while listening for a packet. When a
packet is received, it will return and allow me to
process the data.
The problem is, if I release/renew my IP address while in the blocking
Receive() call, it will block forever. Even though I successfully
reestablish network connectivity and there are plenty of UDP packets
available, this call never returns. Ideally Receive() should throw a socket
error when I lose network connectivity.
I can always force this call to throw by calling UdpClient.Close() on
another thread, but this would require another thread just to monitor
network connectivity and make the UdpClient throw when it
should. I'd hate to have to add another thread just for that.
Is there a better way to do this?
Thank you,
-Jim