multithreading problem in C++

HJB417

Senior member
Dec 31, 2000
763
0
0
in gamespy, it can ping up to 64 servers simultaneously. It uses multithreading, 1 thread per ping but the CPU utilization is close to nothing. I tried to follow the same pattern but my cpu utilization stays at 100 until all the pings are done. I made all the ping threads background threads and putting the main thread to sleep until all the worker threads were done but it still stays at 100% cpu utilization while pinging.
Can anyone help?
 

Argo

Lifer
Apr 8, 2000
10,045
0
0
It has nothing to do with multithreading but rather with your program design. Most probably it's related to how you're invoking ping.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Also remember Gamespy pings aren't just ICMP echo requests, they connect to the server and get the info on players too, so they probably use the same method quake uses via udp to determine your latency.
 

HJB417

Senior member
Dec 31, 2000
763
0
0
good points..
hmm.
but quake goobles up all your cycles anyway =0
true about gspy connecting to udp, and the almost all the ips on the list are respondable game machines...

about my invoking of ping, this is what my worker thread looks like.
I'm just trying to make a d2 game finder
1. ping all possible ips of my range. add ones that ping in 10ms or less to a file
2. loop the file connection to port 4000
3. trigger event when a connection to port 4000 has been made.

also, how can I find the IP range my school uses? Right now, I'm scanning 64000 IPs but there are at most, 2,500~3,000 computers here. =(