I've written a ping program for Windows using raw sockets, and it works really well.

However if I run the program twice simultaniously, the packets end up getting picked up by the wrong process and dropped when the ID doesn't match.

I thought about polling recvfrom with MSG_PEEK, but everything I read on this topic tells me MSG_PEEK is bad.

There are no port numbers for me to bind a process to, so how can I get around this?
The only thought I have left is to read all ICMP packets into a buffer and then check which ID's correspond to what process, then send them there. This seems like a bit of a hack though.

Any thoughts appricieted.