PHP networking

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
arvinsmendoza
Forum Newbie
Posts: 2
Joined: Tue May 29, 2007 5:29 am

PHP networking

Post 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... :)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: PHP networking

Post 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.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

I frequently skip posts marked urgent, actually. Too often those posters just want us to do their work for them.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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');
arvinsmendoza
Forum Newbie
Posts: 2
Joined: Tue May 29, 2007 5:29 am

Re: PHP networking

Post 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..
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Why did you put your question in a quote? Weird.

Anyway, the answer is no. There aren't.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

You might be looking for snmp
Post Reply