While copy != INVALID_SOCKET, but I get a "The system detected an
invalid pointer address in attempting to use a pointer argument in a
call." when I try to do a WSARecv. I should probably try a windows
forum instead.
 
I didn't try to debug your code, but at a glance, it seems that when duplicating socket, you pass current process id instead of *target* process id.