How i know a IP is connected/normal or disconnected from LAN in PHP?
I have a database where i have stored all IP address. Now i want to know these IP address is connected/normal or disconnected. I have tried:
$add = "example.com";
$result = checkdnsrr($add, "MX");
var_dump($result);
Its return boolean true
or false
. But i have IP address which is not connected dns. But how can i know the IP is active/normal/connected or disconnected?
php ip lan
add a comment |
I have a database where i have stored all IP address. Now i want to know these IP address is connected/normal or disconnected. I have tried:
$add = "example.com";
$result = checkdnsrr($add, "MX");
var_dump($result);
Its return boolean true
or false
. But i have IP address which is not connected dns. But how can i know the IP is active/normal/connected or disconnected?
php ip lan
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago
add a comment |
I have a database where i have stored all IP address. Now i want to know these IP address is connected/normal or disconnected. I have tried:
$add = "example.com";
$result = checkdnsrr($add, "MX");
var_dump($result);
Its return boolean true
or false
. But i have IP address which is not connected dns. But how can i know the IP is active/normal/connected or disconnected?
php ip lan
I have a database where i have stored all IP address. Now i want to know these IP address is connected/normal or disconnected. I have tried:
$add = "example.com";
$result = checkdnsrr($add, "MX");
var_dump($result);
Its return boolean true
or false
. But i have IP address which is not connected dns. But how can i know the IP is active/normal/connected or disconnected?
php ip lan
php ip lan
edited 13 hours ago
asked 13 hours ago
Chonchol Mahmud
1,90711439
1,90711439
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago
add a comment |
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago
add a comment |
2 Answers
2
active
oldest
votes
LONG POLLING is BAD
As far as I have understood your question, you just want to check if the particular client is connected or not.
You will have to setup a cron job in PHP with a continuous loop which will be long polled by XHR (AJAX with Jquery etc) setting a status = true
. So, when a user disconnects, the XHR will be broken and a status will be set = false
. Thus you can check if a user is connected or not. However, please note that Long Polling is really resource intensive and is not appreciated.
I would highly suggest you to use go with Node
and Websockets
etc.
I could write a code for PHP Cron job and settle your problem but I don't appreciate Long Polling + Cron Job for it.
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google forNode + Websockets
and it will bring a list of tons of websites teaching it.
– Abdul Jabbar Dumrai
13 hours ago
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
add a comment |
if you want to check if the website is alive then you can do it like this:
$add = "example.com";
$result = false;
if($fp = fsockopen($add, 80, $errno, $errstr, 10)){
fclose($fp);
$result = true;
}
var_dump($result);
// edit: so you want to know if the IP is present in your local network ? if so you can use ping like:
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "x08x00x7dx4bx00x00x00x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255))
$result = microtime(true) - $ts;
else $result = false;
socket_close($socket);
return $result;
}
$present = ping('192.168.0.100');
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942587%2fhow-i-know-a-ip-is-connected-normal-or-disconnected-from-lan-in-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
LONG POLLING is BAD
As far as I have understood your question, you just want to check if the particular client is connected or not.
You will have to setup a cron job in PHP with a continuous loop which will be long polled by XHR (AJAX with Jquery etc) setting a status = true
. So, when a user disconnects, the XHR will be broken and a status will be set = false
. Thus you can check if a user is connected or not. However, please note that Long Polling is really resource intensive and is not appreciated.
I would highly suggest you to use go with Node
and Websockets
etc.
I could write a code for PHP Cron job and settle your problem but I don't appreciate Long Polling + Cron Job for it.
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google forNode + Websockets
and it will bring a list of tons of websites teaching it.
– Abdul Jabbar Dumrai
13 hours ago
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
add a comment |
LONG POLLING is BAD
As far as I have understood your question, you just want to check if the particular client is connected or not.
You will have to setup a cron job in PHP with a continuous loop which will be long polled by XHR (AJAX with Jquery etc) setting a status = true
. So, when a user disconnects, the XHR will be broken and a status will be set = false
. Thus you can check if a user is connected or not. However, please note that Long Polling is really resource intensive and is not appreciated.
I would highly suggest you to use go with Node
and Websockets
etc.
I could write a code for PHP Cron job and settle your problem but I don't appreciate Long Polling + Cron Job for it.
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google forNode + Websockets
and it will bring a list of tons of websites teaching it.
– Abdul Jabbar Dumrai
13 hours ago
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
add a comment |
LONG POLLING is BAD
As far as I have understood your question, you just want to check if the particular client is connected or not.
You will have to setup a cron job in PHP with a continuous loop which will be long polled by XHR (AJAX with Jquery etc) setting a status = true
. So, when a user disconnects, the XHR will be broken and a status will be set = false
. Thus you can check if a user is connected or not. However, please note that Long Polling is really resource intensive and is not appreciated.
I would highly suggest you to use go with Node
and Websockets
etc.
I could write a code for PHP Cron job and settle your problem but I don't appreciate Long Polling + Cron Job for it.
LONG POLLING is BAD
As far as I have understood your question, you just want to check if the particular client is connected or not.
You will have to setup a cron job in PHP with a continuous loop which will be long polled by XHR (AJAX with Jquery etc) setting a status = true
. So, when a user disconnects, the XHR will be broken and a status will be set = false
. Thus you can check if a user is connected or not. However, please note that Long Polling is really resource intensive and is not appreciated.
I would highly suggest you to use go with Node
and Websockets
etc.
I could write a code for PHP Cron job and settle your problem but I don't appreciate Long Polling + Cron Job for it.
edited 13 hours ago
answered 13 hours ago
Abdul Jabbar Dumrai
3,12153260
3,12153260
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google forNode + Websockets
and it will bring a list of tons of websites teaching it.
– Abdul Jabbar Dumrai
13 hours ago
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
add a comment |
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google forNode + Websockets
and it will bring a list of tons of websites teaching it.
– Abdul Jabbar Dumrai
13 hours ago
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
Please could you write up PHP cron Job or give me some useful links for node and websockets. Appreciated.
– Chonchol Mahmud
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google for
Node + Websockets
and it will bring a list of tons of websites teaching it.– Abdul Jabbar Dumrai
13 hours ago
@ChoncholMahmud itnext.io/… for more, you can Google for
Node + Websockets
and it will bring a list of tons of websites teaching it.– Abdul Jabbar Dumrai
13 hours ago
1
1
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
@ChoncholMahmud for more robust system, use Socket.io with Node. As this will cover a wide area of old browsers as well. Off Course, if you are newbie to Node, you will have to learn it but trust me it's really easy and worth learning it.
– Abdul Jabbar Dumrai
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
Thank you very much for you good suggestion. Yes, I am newbie in Node. That's why i want solve this problem with PHP.
– Chonchol Mahmud
13 hours ago
add a comment |
if you want to check if the website is alive then you can do it like this:
$add = "example.com";
$result = false;
if($fp = fsockopen($add, 80, $errno, $errstr, 10)){
fclose($fp);
$result = true;
}
var_dump($result);
// edit: so you want to know if the IP is present in your local network ? if so you can use ping like:
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "x08x00x7dx4bx00x00x00x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255))
$result = microtime(true) - $ts;
else $result = false;
socket_close($socket);
return $result;
}
$present = ping('192.168.0.100');
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
add a comment |
if you want to check if the website is alive then you can do it like this:
$add = "example.com";
$result = false;
if($fp = fsockopen($add, 80, $errno, $errstr, 10)){
fclose($fp);
$result = true;
}
var_dump($result);
// edit: so you want to know if the IP is present in your local network ? if so you can use ping like:
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "x08x00x7dx4bx00x00x00x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255))
$result = microtime(true) - $ts;
else $result = false;
socket_close($socket);
return $result;
}
$present = ping('192.168.0.100');
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
add a comment |
if you want to check if the website is alive then you can do it like this:
$add = "example.com";
$result = false;
if($fp = fsockopen($add, 80, $errno, $errstr, 10)){
fclose($fp);
$result = true;
}
var_dump($result);
// edit: so you want to know if the IP is present in your local network ? if so you can use ping like:
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "x08x00x7dx4bx00x00x00x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255))
$result = microtime(true) - $ts;
else $result = false;
socket_close($socket);
return $result;
}
$present = ping('192.168.0.100');
if you want to check if the website is alive then you can do it like this:
$add = "example.com";
$result = false;
if($fp = fsockopen($add, 80, $errno, $errstr, 10)){
fclose($fp);
$result = true;
}
var_dump($result);
// edit: so you want to know if the IP is present in your local network ? if so you can use ping like:
function ping($host, $timeout = 1) {
/* ICMP ping packet with a pre-calculated checksum */
$package = "x08x00x7dx4bx00x00x00x00PingHost";
$socket = socket_create(AF_INET, SOCK_RAW, 1);
socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
socket_connect($socket, $host, null);
$ts = microtime(true);
socket_send($socket, $package, strLen($package), 0);
if (socket_read($socket, 255))
$result = microtime(true) - $ts;
else $result = false;
socket_close($socket);
return $result;
}
$present = ping('192.168.0.100');
edited 13 hours ago
answered 13 hours ago
Kazz
384313
384313
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
add a comment |
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
I want to check IP is connected or disconnected to LAN.
– Chonchol Mahmud
13 hours ago
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53942587%2fhow-i-know-a-ip-is-connected-normal-or-disconnected-from-lan-in-php%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
checkdnsrr will get domain information where available. This is not the same as a user being connected. To detect this you would need to implement some sort of a background list where IP addresses are stored against a date/last visited. It could also be archived with the use of js
– atoms
13 hours ago
@atoms so how can i achieve my goal? Can you give me any idea in PHP or JS?
– Chonchol Mahmud
13 hours ago
not really. I've pointed you in the right direction. Abdul has given some good information too. Think about having a list in memory. Each user has a record in the list. Just maintain the list's data and you will have what you want
– atoms
13 hours ago