March 3rd, 2014, 11:56 AM
Reading UDP packets works but only works again after a timeout.
I have a problem that is driving me demented.
I have a PC running XP (or W7, makes no difference) that has a direct Ethernet connection to a DSP (no routers in the way).
After reset, the DSP sends BOOTP packets to the PC as it waits to be loaded.
The PC detects these BOOTP packets using Winpcap.
On receiving a BOOTP, the PC sends a small program to the DSP using UDP.
The PC then opens a socket and reads a UDP packet from a specific port (actually 0xC0C0).
When the DSP starts, it broadcasts an ARP to find the host then sends a UDP packet to port 0xC0C0 on the host.
If I run this, it works.
The PC detects the BOOTP, loads the DSP, which sends the ARP and gets a response, the DSP sents its UDP packet and the PC gets it.
If I immediately reset the DSP and run the PC program again (having closed it down after the previous run), the PC detects the BOOTP, loads the DSP, which sends the ARP and gets a response, and the DSP sents its UDP packet (all verified by Wireshark on the PC), but the PC program then never sees any incoming packet.
Instead, if I wait a minute or so after a successful run, I can run again without problems (the incoming UDP packet is read correctly).
I have verified that the data being sent in both directions are always the same on every run.
All the Winsock calls on the PC execute with success returns.
It appears that something in Windows is taking a long time (of the order of a minute) to close the socket at the end of a run and, in the meantime, it is absorbing incoming packets and discarding them. This must be happening AFTER Windows has happily opened the socket for the next run.
As the PC program is shut down between runs, there cannot be any memory of previous runs in the program itself.
It must be something strange happening in Windows.
I have been chasing this problem for a very long time now and I am no closer to a solution.
Any suggestions would be gratefully received.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!