PHP Network

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

User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

ghadacr wrote:]This is how i know you dont know what your doing first you try to give me an anwser trying to use Java, and this is a PHP forum :?
Hu, this is a php forum? Why didn't anybody tell me? Boahy, I'm so embarrassed now.
ghadacr wrote:Second of all the code you gave me, of course it does not work first thing i noticed about your internet example copied code was
Of course the code didn't work. It's only a "here, I did what you told me. It doesn't work. So what did you really do".
ghadacr wrote:Of course its not going to work, if you dont close the comments within the code.... :roll:
Let's assume for just one moment that was the case. Then I would have gotten a compiler error?. But I didn't, I got the output "PC Switched Off".
And // automagically ends at the end of the line, nothing to close here.
ghadacr wrote:Secondly you have to go into more detail about the specfic port numbers and IP address.....
Wow, now you finally relaize there's more information needed. Splendid.
ghadacr wrote:All i ask for is some direction whether PHP incoprates network capabilties....
Yes, you can find the documentation at http://de2.php.net/manual/en/index.php Search the page for "Network Functions".


p.s.: :roll:
Last edited by volka on Fri Jun 15, 2007 11:07 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

volka is trying to help you and you keep avoiding his request for more information to help you with. What he is after is your approach in Java to see if there is a translation available in PHP, which I doubt there is. But we won't know that because every response of yours is opposition to his request for more information.

Tell us what and how you achieved what you wanted in Java and we can see if there is something comparable that can be done in PHP.

And for the record, volka knows pretty damn well what he is doing. Just ask the thousands of users he has helped over the years.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Everah wrote:And for the record, volka knows pretty damn well what he is doing. Just ask the thousands of users he has helped over the years.
But also note that he can get grumpy, sarcastic and even mean under certain circumstances. Current role model: Gregory House.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

volka wrote:
Everah wrote:And for the record, volka knows pretty damn well what he is doing. Just ask the thousands of users he has helped over the years.
But also note that he can get grumpy, sarcastic and even mean under certain circumstances. Current role model: Gregory House.
Nice. Sometimes I wish I could be that big of a bastard without getting shot in the face with an uzi. Image
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

so that's the reason behind
PHPDN's Most Friendly Award, 2006 [...] Friendliest 2007
fear
:D
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Post by ghadacr »

All i wanted was some help, not a full blown argument...Right i dont have the Java code with me, thats on another machine, but the code that you got is similiar to mine. although miine goes into more detail about port numbers and ip address. so if the IP gets pinged first and if its alive then it will try to make a connection to the socket.

Secondly, the java code checks whether a socket can be established...(some scokets can not be opended dependant on the network security setup on machine, firewalls could be blocking the socket connection)

so basically what the java code does is:

1st: Ping PC
2: If PC is alive then try to make connection
3: If connection is established then make socket connection
4: if socket connection is established then ouput result else output "PC SHUTDOWN"

I hope that anwsers your questions


Peace.....No fighting... Also House always comes up with a solution at the end, so i hope i get a solution with all these posts :wink:
User avatar
ghadacr
Forum Contributor
Posts: 135
Joined: Fri May 11, 2007 10:44 am

Post by ghadacr »

Nobdy likes being a bastard, but people respond differetely if we didnt then we all would be robots..... :twisted:

Actually i think some people would like that.... Hmmm i wonder who.. only jokin

Well done on your prize. did you get any money???
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I leave out 1st: Ping PC. If the socket connection can be established the pc is obviously on and functional.
This might be your criteria for distingushing
ghadacr wrote:SHUTDOWN, LOGGEDOFF
but how would I know?

Code: Select all

<?php
// e.g. 'localhost', '192.168.0.1', 'mumspc', 'php.net', anything your pc can resolve
$host = 'localhost';
// as integer
$port = 80; 

// localhost:80, that would be my apache server
$sd = @fsockopen($host, $port, $errno, $errstr, 1.0 /* one second timeout */);

if ( !$sd ) {
	echo "unable to connect {$host}:{$port} \n reason: $errstr ($errno)";
}
else {
	echo $host, ':', $port, ' successfully connected';
}
?>
But still there must be a program/service/application running on all the pcs you want to monitor that accepts the connection request. Hopefully you chose a standard service that really is running on all those pcs and is available within your network.
Post Reply