Thanks Martin for sharing the pain.
I was checking the ip address of the requesting computer to see if it matched the first computer that originally connected.
If the new connection didn't have the same ip address I would ignore it and return to the accept to look for a new connection.
This was an error because a new socket is created every time you break out of the accept.
Eventually you will run out of memory.
So I added a shutdown if the ip didn't match.
This is also an error because the foreign computer wouldn't give up and continued trying to connect.
So I now accept the connection from the foreign computer and create a socket for it but my comms routine ignores it.
This satisfies the foreign computer and it stops the SYN/ACK attack.