Page 1 of 1

PHP networking

Posted: Tue May 29, 2007 5:39 am
by arvinsmendoza
I need help.. Do you know how to automatically detect the IP adddresses in the LAN using PHP? I know that there are many networking functions in this programming language, but I'm really confuse on how to use them..

Please respond.. I need it urgently..

Thanks... :)

Re: PHP networking

Posted: Tue May 29, 2007 6:51 am
by onion2k
arvinsmendoza wrote:I need help.. Do you know how to automatically detect the IP adddresses in the LAN using PHP? I know that there are many networking functions in this programming language, but I'm really confuse on how to use them..
You'll need to loop through all the valid IP addresses in your networks IP range and ping them. There's a bunch of ping libraries available. There's definitely one in PEAR, or there's a tutorial for writing your own here: http://www.planet-source-code.com/vb/sc ... odeId=1786 ... one thing to note: if you're in a big network it'll take ages because PHP doesn't do concurrent sockets very well. You might be able to get somewhere with an array of non-blocking sockets and looping through them, but that's not something I've ever tried.

Needlesstosay, that will only detect computers that respond to pings. If they've got firewalls, or the ping service is turned off, then the IP address will appear to be dead even though it's not. There's not really any sensible way around that though.
Please respond.. I need it urgently..
Do you really think people on here are reading posts and thinking "I'll reply to that tomorrow. Oh, wait, it's really urgent, I'll reply today!". Because they're not. Saying that sort of thing is pointless.

Posted: Tue May 29, 2007 8:33 am
by Kieran Huggins
I frequently skip posts marked urgent, actually. Too often those posters just want us to do their work for them.

Posted: Tue May 29, 2007 8:35 am
by feyd
Kieran Huggins wrote:I frequently skip posts marked urgent, actually. Too often those posters just want us to do their work for them.
indeed.

Posted: Tue May 29, 2007 9:29 am
by Chris Corbyn
You can actually ping an entire broadcast address although it's unreliable. pinging itself is unreliable anyway. I drop pings at home.

Code: Select all

exec('ping -b 192.168.1.255');

Re: PHP networking

Posted: Wed May 30, 2007 9:18 pm
by arvinsmendoza
onion2k wrote:
arvinsmendoza wrote:I need help.. Do you know how to automatically detect the IP adddresses in the LAN using PHP? I know that there are many networking functions in this programming language, but I'm really confuse on how to use them..
You'll need to loop through all the valid IP addresses in your networks IP range and ping them. There's a bunch of ping libraries available. There's definitely one in PEAR, or there's a tutorial for writing your own here: http://www.planet-source-code.com/vb/sc ... odeId=1786 ... one thing to note: if you're in a big network it'll take ages because PHP doesn't do concurrent sockets very well. You might be able to get somewhere with an array of non-blocking sockets and looping through them, but that's not something I've ever tried.

Needlesstosay, that will only detect computers that respond to pings. If they've got firewalls, or the ping service is turned off, then the IP address will appear to be dead even though it's not. There's not really any sensible way around that though.
Please respond.. I need it urgently..
Do you really think people on here are reading posts and thinking "I'll reply to that tomorrow. Oh, wait, it's really urgent, I'll reply today!". Because they're not. Saying that sort of thing is pointless.
Is there any other networking functions that would get the system information of the given IP address?.. Thanks..

Posted: Thu May 31, 2007 3:30 am
by onion2k
Why did you put your question in a quote? Weird.

Anyway, the answer is no. There aren't.

Posted: Thu May 31, 2007 4:11 am
by volka
You might be looking for snmp