I have a udp service which is listening on a socket for udp datagrams:
int result = 0;
try
{
result = m_ReceivingSocket.Receive(buffer);
}
catch (SocketException e)
{
Log.Debug("Timed out with socket exception, so no result was found.", e);
}
It does this on a Timer every 1 millisecond because it is important that I get the udp message asap. Most of the time a socket exception is thrown because the socket will time out. This is because the socket is set up to time out:
receivingSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 1000);
Unfortunately, when I run this, the Visual Studio debugger does not allow me to step through code. It thinks that another thread keeps running and won't let me proceed. Anybody seen this before? Anyone know of a better way to receive from a socket without dealing with exceptions?