Detect "Ping"?
BlitzMax Forums/BlitzMax Programming/Detect "Ping"?
| ||
Hi everyone! I'm looking for a simple way to detect the "ping" of an IP address. I'd like to give the users of my radio player an easy method to check how far away they are from a radio stream server. Is this possible without coding a complete multiplayer engine? ;) Grisu Last edited 2010 |
| ||
proc:TProcess=TProcess.Create("c:\windows\system32\ping.exe ip.ip.ip.ip") pipe=proc.pipe and so on, look in pub.freeprocess for mor information Last edited 2010 |
| ||
argh Last edited 2010 |
| ||
You simply create a millisecs() variable, send a signal of choice do the radio stream server, and then send a response to the client and the client just goes: print "Ping: " + Millisecs() - MillsecsVar ^^ Or am I too hungover for this? :P |
| ||
I need a cross-platform solution. To just call ping.exe won't do it. :( Last edited 2010 |
| ||
Calling just CreateProcess("ping 127.0.0.1") should work fine on all platforms. |
| ||
Could one of you make up an example code. I'm completely new to this thread stuff. Plus the bmx docs aren't of much help. SuperStrict Framework Brl.EventQueue Import BRL.StandardIO Import PUB.freeprocess Global proc:TProcess=TProcess.Create("ping www.pulsradio,com",0) Print "Ping? " |
| ||
im sure you can modify this to your needs...:SuperStrict Framework Brl.EventQueue Import BRL.StandardIO Import PUB.freeprocess Global proc:TProcess=TProcess.Create("ping www.pulsradio.com",0) While proc If proc.pipe.ReadAvail() Local a:String a = proc.pipe.ReadLine() Print a EndIf Wend this is my output: Ping-is„nt„: www.pulsradio.com [88.191.88.14] 32 tavua tietoja: Vastaus is„nn„lt„ 88.191.88.14: tavuja=32 aika=59 ms TTL=51 Vastaus is„nn„lt„ 88.191.88.14: tavuja=32 aika=56 ms TTL=51so you cannot use find("time=").. instead just take 3nd last text... time=xxx aika=xxx (last is TTL=xxx 2.last is ms 3. last is aika=xxx or time=xxx or whatever is your locale ) line.split(" ")... etc.. you know this..... Last edited 2010 |
| ||
I will, thanks a lot. Well, my app is multilingual, but I think the output should be similar on each os / language. Last edited 2010 |