Im pinging servers..and ive gotten it to go really fast, but i want to see which ones are the fastest (thus pinging) since im doing it so fast with a for loop i cant use gettickcount since it finishes the loop before it goes to the winsock.getdata..
I hope you get it..im going for speed here, and those ping API's just dont cut it..
What do you mean they don't come back with a ping?
You get a response, right?
yes, but i was using gettickcount or queryperformancecounter before..And now since im using a for next loop they all get sent data, and respond after im done sending to all the servers. I dont want to ping them after word, very time consuming...I dont know how to make it any clearer..
Doevents is a possible solution but it should be used with care. You can easily run into out of stack memory problems if doevents is abused/misused. And it'll consume cpu time from switching.
Are you really doing a "ping" the way most people understand it or (based on the code you provided) are you refering to packets sent by the remote host due to dataarrival event (on the remote host) code? But anyway...
How precise do you need the timing info? seconds? milliseconds? Why not send them by batches and check for results on a given period (say every half second, etc).
So if you had a matrix, you can add one column (a counter) that's updated (every half second) for those IPs still waiting for replies. So an IP sent in the first batch, still has no reply after sending the second batch will have a count of 0.5. If still no reply after the third batch 0.5 is updated to 1 sec delay and so on.
Although a table or collection (so you have a primary key based on IP-port) would be more convenient to use since you can have an element direct update instead of looping through the array again just to update one delay status.
Last edited by leinad31; Oct 2nd, 2005 at 10:11 AM.
Of course what you're doing isn't a true ping.
Only the servers you contact on port 80 are responding to your message.
I deleted all winsock controls except 0 then loaded them in the loop.
I put the code into a command button.
Found a few mistakes, try this.
VB Code:
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" ( _
but if i have like 200 ips..wont loading all those winsocks kill ram or something? Doesnt the winsock control like "leak" into memory when you have so many?
I don't think you will leak memory. 200 controls is certainly doable.
If you want to do this with one control then you'll have to do them all sequentially. That is: send message to server, get response, send message to next server, get response,...