The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Detection and Display using Javascript
s3s3
post Mar 17 2012, 06:47 AM
Post #1





Group: Members
Posts: 5
Joined: 17-March 12
Member No.: 16,732



I have a LAN where several boards are connected, each having its own (known) ip adress. I am controlling them through HTML (toggling leds, reading temperature etc). I would also like to add a function which shows which board is connected, so that I don't have to check this manually. How could this be done in HTML and/or javascript?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 17 2012, 09:32 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



AFAIK none of that can be done with HTML or javascript.

If you set up a local server, you might let a server-side script on it check when browsers with IPs from the different computer logged in last time.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
s3s3
post Mar 17 2012, 09:51 AM
Post #3





Group: Members
Posts: 5
Joined: 17-March 12
Member No.: 16,732



QUOTE(Christian J @ Mar 17 2012, 09:32 AM) *

AFAIK none of that can be done with HTML or javascript.

If you set up a local server, you might let a server-side script on it check when browsers with IPs from the different computer logged in last time.


I don't have computers in the network but boards with only a tcp/ip stack on them and a local html page which I see when I connect manually to their ip with a browser.
I'm only interested to know which board is conected at the time of wathcing. I'm not interested in any history. I want to open a webpage and see which board is online. Boards which are connected are constantly sending packets so i just have to somehow identify who sent the packets. And this should be done in a browser.

This post has been edited by s3s3: Mar 17 2012, 09:52 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
XP1
post Mar 17 2012, 10:39 AM
Post #4





Group: Members
Posts: 7
Joined: 14-March 12
Member No.: 16,709



The unintelligent way to do this is to use JavaScript to check the response of the web server.

Unintelligent means that it does not know that when the web server is down, it can still be connected to the network. Using the unintelligent method means that the only way to check would be that the web server must be online.

Is the unintelligent method acceptable to you?

This post has been edited by XP1: Mar 17 2012, 10:40 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
s3s3
post Mar 17 2012, 12:04 PM
Post #5





Group: Members
Posts: 5
Joined: 17-March 12
Member No.: 16,732



QUOTE(XP1 @ Mar 17 2012, 10:39 AM) *

The unintelligent way to do this is to use JavaScript to check the response of the web server.

Unintelligent means that it does not know that when the web server is down, it can still be connected to the network. Using the unintelligent method means that the only way to check would be that the web server must be online.

Is the unintelligent method acceptable to you?


Unintelligent way seems ok since if the web server on the board is down it doesnt matter if te board is still connected or not, what would I have to use in order to accomplish this "unintelligent" way? give me a starting point smile.gif

And since u mentioned the unintelligent way, What would be the inteligent way to do it then?(just for the sake of curiosity)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
XP1
post Mar 17 2012, 01:29 PM
Post #6





Group: Members
Posts: 7
Joined: 14-March 12
Member No.: 16,709



QUOTE(s3s3 @ Mar 17 2012, 01:04 PM) *
Unintelligent way seems ok since if the web server on the board is down it doesnt matter if te board is still connected or not, what would I have to use in order to accomplish this "unintelligent" way? give me a starting point smile.gif
You could try XMLHttpRequest, but most modern browsers will block access to the local network.

CODE
var request = new XMLHttpRequest();
request.open("GET", "http://127.0.0.1/", false);
request.send(null);

console.log("Request status: " + request.status);

if (request.status === 200)
{
    console.log("The web server responded.");
}

You could also try to find an image hosted on the web server.

CODE
var image = new Image();
image.src = "http://127.0.0.1/image.png";
image.onload = function onload()
{
    console.log("The web server responded.");
};


QUOTE(s3s3 @ Mar 17 2012, 01:04 PM) *
And since u mentioned the unintelligent way, What would be the inteligent way to do it then?(just for the sake of curiosity)
An intelligent method would not rely on a web server to check network connectivity because an offline web server does not mean that the client is disconnected from the network. A smarter program would try pinging and would probably monitor the local network for client activity as a fallback.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
s3s3
post Mar 17 2012, 08:27 PM
Post #7





Group: Members
Posts: 5
Joined: 17-March 12
Member No.: 16,732



QUOTE
An intelligent method would not rely on a web server to check network connectivity because an offline web server does not mean that the client is disconnected from the network. A smarter program would try pinging and would probably monitor the local network for client activity as a fallback.


Will I be able to include somehow that smarter program in an Html page? Lets say I make an application in C, can I include it in the webpage? Or u are suggesting to just plain drop the webpage approach and go for an independent application written in a certain language that allows me to do what I need ?

This post has been edited by s3s3: Mar 17 2012, 08:27 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
XP1
post Mar 17 2012, 09:06 PM
Post #8





Group: Members
Posts: 7
Joined: 14-March 12
Member No.: 16,709



QUOTE(s3s3 @ Mar 17 2012, 09:27 PM) *
Will I be able to include somehow that smarter program in an Html page? Lets say I make an application in C, can I include it in the webpage?
Maybe something like a browser plugin or Native Client?
https://developers.google.com/native-client/

I haven't tried Native Client, but it looks interesting.

QUOTE(s3s3 @ Mar 17 2012, 09:27 PM) *
Or u are suggesting to just plain drop the webpage approach and go for an independent application written in a certain language that allows me to do what I need ?
If you only need to check the web server status, then the unintelligent method is fine. If you need to check connectivity even if the web server goes down, then you can't rely on the unintelligent method.

This post has been edited by XP1: Mar 17 2012, 09:07 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th March 2024 - 03:03 AM