tags:

views:

287

answers:

1

I've developed some software on my Desktop which runs Windows 7 and the software appears to work perfectly. The software seems to work well on our Vista laptop too. However I'm having some issues getting it working on XP.

The software starts with a discovery tool which sends out UDP broadcast messages on port 46787 and listens for replys from devices on this same port. This works on all three OS's.

Once a discovered device has been selected the discovery UDP cient is stopped. Then Another UDP client is started on port 46788 to listen for data from the device:

            receiverUDP = new UdpClient("255.255.255.255", 46788);
            receiverUDP.EnableBroadcast = true;

            // Start receiving Async UDP packets
            receiverUDP.BeginReceive(new AsyncCallback(ReceiveUDP), receiverUDP);

On XP this throws a System.Net.Sockets.SocketException when EndReceive is called, but it works perfectly in Vista/Win7 and I get my data streamed through...

System.Net.Sockets.SocketException: The I/O operation has been aborted because of either a thread exit or an application request
   at System.Net.Sockets.Socket.EndReceiveFrom(IAsyncResult asyncResult, EndPoint& endPoint)
   at System.Net.Sockets.UdpClient.EndReceive(IAsyncResult asyncResult, IPEndPoint& remoteEP)
   at Demo.IOPanel.ReceiveUDP(IAsyncResult result) in C:\...\IOPanel.cs:line 262
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.CompleteCallback(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Windows firewall is disabled, there are no other firewalls installed. I've checked using netstat and nothing else is using that port. Ive tried 5 other random ports and it still doesnt work.

I know that the stack was completely re-written for Vista, so whats changed? Shouldnt .Net hide all these differences?

+1  A: 

Is it possible that the thread calling BeginReceive terminates at some point? This works in Vista but not in XP; see this related question and the comments of the accepted answer.

Heinzi
Yep, the thread terminates. The discovery tool does not use a thread for the BeginReceive so this must be the issue!
Tim