aaronk Well-Known Member Licensed User Longtime User Apr 13, 2014 #1 Hi, Just wondering how I can ping a IP address and get a reply back saying Pass or Fail if it was able to be pinged. I have used the following code but I can't work out how to make it say Pass or Fail Code: Dim p As Phone Dim sb As StringBuilder sb.Initialize p.Shell("ping -c 1 192.168.0.1",Null,sb,Null) Log(sb) Anyone able to help so it only says Pass or Fail if the IP was able to be pinged ?
Hi, Just wondering how I can ping a IP address and get a reply back saying Pass or Fail if it was able to be pinged. I have used the following code but I can't work out how to make it say Pass or Fail Code: Dim p As Phone Dim sb As StringBuilder sb.Initialize p.Shell("ping -c 1 192.168.0.1",Null,sb,Null) Log(sb) Anyone able to help so it only says Pass or Fail if the IP was able to be pinged ?
Erel B4X founder Staff member Licensed User Longtime User Apr 13, 2014 #2 You will need to parse the text response. Make sure to read StdErr as well. However I don't recommend you to use this code as it will block the main thread. If there is a http server running on this address then you can use HttpUtils2 to check the connection. Upvote 0
You will need to parse the text response. Make sure to read StdErr as well. However I don't recommend you to use this code as it will block the main thread. If there is a http server running on this address then you can use HttpUtils2 to check the connection.
aaronk Well-Known Member Licensed User Longtime User Apr 13, 2014 #3 Erel said: However I don't recommend you to use this code as it will block the main thread. Click to expand... What do you mean block the main thread ? As my app will connect to a TCP socket using a port number, I want to add something to the app (such as ping test) so if the user can't connect to the IP/port they can run some type of test and see if the device can talk to that IP or not. Upvote 0
Erel said: However I don't recommend you to use this code as it will block the main thread. Click to expand... What do you mean block the main thread ? As my app will connect to a TCP socket using a port number, I want to add something to the app (such as ping test) so if the user can't connect to the IP/port they can run some type of test and see if the device can talk to that IP or not.
Erel B4X founder Staff member Licensed User Longtime User Apr 13, 2014 #4 The main thread will block until the ping completes. Upvote 0
NJDude Expert Licensed User Longtime User Apr 13, 2014 #5 Look at THIS example, but like Erel said above, this code will block the main thread until the ping routine completes. Upvote 0
Look at THIS example, but like Erel said above, this code will block the main thread until the ping routine completes.