By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,475 Members | 954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,475 IT Pros & Developers. It's quick & easy.

Multi-threaded ping application

P: n/a
I am trying to write a ping application that uses multiple threads to ping numerous hosts. I have copied the code from KB 828993 ( http://support.microsoft.com/default...b;EN-US;828993 ). This works fine, however I added code to ensure that #1 - the response type is a ping echo (to ensure it wasn't a TTL expired, etc...), and I implemented the Identifier code (currently it uses only 45). This works fine if I use only one thread and run it synchronously. However, if I run it with multiple threads, I get packets that seem crossed. Here's an example:

Host: 1.1.1.1
Sent Packet ID (using Socket.SentTo): 5000
Received Packet ID (using Socket.ReceiveFrom): 9000

Host: 2.2.2.2
Sent Packet ID (using Socket.SentTo): 9000
Received Packet ID (using Socket.ReceiveFrom): 5000

It appears the packets get crossed. I have solved this using BeginReceiveFrom/EndReceiveFrom, but it seems like there should be an explanation as to why I would be receiving the packet from ReceiveFrom that I sent to another host. I have also tried sending the remote hosts' end point to the ReceiveFrom, and I still get the same problem.

Does anyone know why this is or has anyone run into this same problem?

Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.