I have a PC running XP (or W7, it 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.
A C++ program on 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 opens a socket on port 0xC0C0, then starts the DSP, and waits for a packet to come in.
When the DSP starts, it broadcasts an ARP to find the host then sends it a UDP packet to port 0xC0C0.
If I run this, it works. The PC detects the BOOTP, loads the DSP, which sends the ARP and gets a response. The DSP sends its UDP packet and the PC gets it.
If I immediately close down the PC program, reset the DSP and run the PC program again, the PC detects the BOOTP, loads the DSP, which sends the ARP and gets a response, and the DSP sends its UDP packet (all verified by Wireshark on the PC), but the PC program never sees the 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 terminate the input socket completely 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 on the same port 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.