I may have had a bit of a breakthrough here...
This appears to work...
What I did different was to send the magic packet to a scrap port (9) instead of the open port for my software.
Code:
// build and send magic packet
VOID WakeHost(PSOCKADDR Host)
{ SOCKADDR ha; // host ip and port
BYTE mac[6]; // host mac address
ULONG smac = 6; // size of mac address
BYTE magic[128] = {0}; // magic packet
// make a copy of the sockaddr
memcpy(&ha,Host,sizeof(SOCKADDR));
// switch port
SetHostPort(9,&ha);
// get mac address
SendARP(((PSOCKADDR_IN)&ha)->sin_addr.S_un.S_addr,0,(PULONG)&mac,&smac);
// build magic packet
memset(&magic,255,6);
for ( int x = 6; x < 102 ; x++)
magic[x] = mac[x % 6];
// send to host computer
sendto(hSocket,(PCHAR)&magic,128,0,&ha,sizeof(SOCKADDR)); }
It's woken my win7 machines up about a dozen times so far.
Testing on XP is pending access to a couple of machines, this evening.