I've come across a curious issue I can't seem to debug. My application received packets from a device sending UDP packets over a specific port. After setting up the UDP listener, a while loop triggers the Receive command periodically.
I should be receiving 400 values at every given time interval and I've even set a process to make sure these values are coming through. Below is a snippet of the relevant code:
public UdpClient listener;
IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort);
//where listenPort is an int holding the port values should be received from
listener.ExclusiveAddressUse = false;
listener.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
listener.Client.Bind(groupEP);
if (listener.Client.Connected)
{
listener.Connect(groupEP);
}
//I've actually never seen the app actually enter the code contained above
try
{
while (!done)
{
if (isListenerClosed == false && currentDevice.isConnected)
{
try
{
receive_byte_array = listener.Receive(ref groupEP);
}
catch (Exception ex)
{
throw ex;
}
}
}
}
catch (SocketException ex)
{
throw ex;
}
The odd thing is that the application runs just fine on my PC (both through setup file/Installshield and when run in Visual Studio) but won't receive any data when running off the setup file on a colleague's computer (it runs just fine in his Visual Studio environment). I've also tried attaching Visual Studio to the app's process, where I found that the code runs fine until it reaches listener.Receive
. No exceptions are caught, no errors given in VS, but the code simply stops since no data is received.
Incidentally, both machines are identical (Mac Minis running 64-bit Windows 7 Ultimate N).
I've even included an UnhandledExceptionHandler in the Main Program as follows:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show("Unhandled Exception Caught " + e.ToString());
throw new NotImplementedException();
}
Could this be an issue with Application permissions in Windows? Any ideas on the best approach to pinpointing the issue?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…