rwblinn Posted June 6, 2014 at 06:35 AM Share Posted June 6, 2014 at 06:35 AM Hi, what is the best way, in JavaScript, to fast (=immediate) check if a) the HOST is reachable and b) the bricklet is connencted. There should no delay in response after trying to connect. If an error, then the result to be messaged to the user. Appreciated, Rob Quote Link to comment Share on other sites More sharing options...
photron Posted June 6, 2014 at 01:17 PM Share Posted June 6, 2014 at 01:17 PM Create an IPConnection object and connect it to the host. If connect fails then the host is not reachable. With the connected IPConnection object create an object for the Bricklet and call its getIdentity method. If the method fails with a timeout then the Bricklet is not connected. The default timeout is 2.5 seconds. If that's too long you can make it shorter. How short it can be and still work reliable depends on the TCP/IP connection speed. You'll have to experiment. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.