Simple Ping
BlitzMax Forums/BlitzMax Beginners Area/Simple Ping
| ||
Hi Folks, Does anyone have a basic example of a simple ping for Blitz max? I'm not looking for anything fancy: I'm just trying to create a simple program that lets me periodically ping a list of ip addresses or host names. I can't seem to find any simple examples to do just a single ping and collect the response. I'd prefer not to call the system command ping from outside the program if it is possible? |
| ||
Otus has a ping code here http://www.blitzbasic.com/codearcs/codearcs.php?code=2209 And then you could try BNetEx http://www.blitzbasic.com/Community/posts.php?topic=74887 Or Etna http://www.blitzmax.com/toolbox/toolbox.php?tool=160 Sorry if this doesn't help. |
| ||
Thanks markcw, I think this will help. I've stumbled across one of these already, but I'll look into the other two on the weekend. I really appreciate any help on this. :) |
| ||
Well I couldn't get Otus' BlitzPing or Vertex's BNetEx to work (they failed to connect), and I didn't try Etna because it's a DLL and I'm on Linux. But there's some ping code by Zeke here. But you said you'd rather not use the system ping. http://www.blitzmax.com/Community/posts.php?topic=92767 So there's Tibit's tnet tcp example (which requires a server). http://www.blitzmax.com/Community/posts.php?topic=92344 Or Brucey's libcurl which is basically http/ftp. http://www.blitzmax.com/Community/posts.php?topic=88704 Or Brucey's raknet which uses cegui but seems to be broken somewhere. And Kurix / RepeatUntil / Jimon's raknet which didn't make. And there's a Gnet chat example by Xyle here. But that doesn't have a ping. http://www.blitzmax.com/Community/posts.php?topic=93799 |
| ||
There is an example with ping using "gnet conversion" by boomboommax here. http://www.blitzmax.com/codearcs/codearcs.php?code=1413 And this is a non-oop example with ping using "GNetServerList" by Oddball. http://www.blitzmax.com/codearcs/codearcs.php?code=2818 |
| ||
Well I found you can also use HostIP and DottedIP but this doesn't return the computer's public (or global) ip address (ie. what you get from http://www.whatismyip.com ) and this seems to be by design for security reasons. BlitzSupport posted about it here http://www.blitzmax.com/Community/posts.php?topic=88744 His code is a test to see if you can get the public ip from your local side. Of course you can use the Gnet "lobby" to return the correct public ip. This code shows the usage of HostIp (from brl.socket) which is an Int. I found you can do "gateway" but I'm not sure what that is, apparently your path to the internet, so maybe your ISP ip. So not much use but it does ping website ips. ' simple ping Print "" Print "blank: "+HostIp("")+" "+DottedIP(HostIp("")) Print "localhost: "+HostIp("localhost")+" "+DottedIP(HostIp("localhost")) Print "gateway: "+HostIp("gateway")+" "+DottedIP(HostIp("gateway")) Print "blitzbasic: "+HostIp("www.blitzbasic.com")+" "+DottedIP(HostIp("www.blitzbasic.com")) Print "google: "+HostIp("www.google.com")+" "+DottedIP(HostIp("www.google.com")) |
| ||
Gateway would likely be your local network gateway, which typically is the router one step away from your computer. Not going to be terribly useful for internet-based programs since it will still be an address on your local network, not the WAN side. |
| ||
Well I found you can also use HostIP and DottedIP but this doesn't return the computer's public (or global) ip address (ie. what you get from http://www.whatismyip.com ) and this seems to be by design for security reasons. Not really "for security reasons", but simply because there is no way for the local machine to find out what address it it hidden behind wihtout querying an external source -- the external address isn't visible/advertised on the local network at all. Anyway: dyndns.org has a free service that returns your external LAN IP address in the same manner that whatismyip.com does. I just dusted off some code that I wrote many years ago which will query the dyndns server and return you your address -- uploaded to the code archives, and can be found here: http://www.blitzbasic.com/codearcs/codearcs.php?code=3121 |
| ||
Thanks Munch & xlsior. I still haven't followed this up yet, another project took priority. All useful stuff though, if I do get this finished I'll happily share my results. |