Page 1 of 2
PHP Network
Posted: Fri Jun 15, 2007 6:25 am
by ghadacr
Is there a way of outputting information, about a PC when it has been pinged i.e. SHUTDOWN, LOGGEDOFF and so on.
Thank you....
Posted: Fri Jun 15, 2007 6:47 am
by volka
An icmp ping does not contain such informations.
What are you trying to achieve?
Posted: Fri Jun 15, 2007 8:46 am
by ghadacr
I want to determine whether a PC is either LOGGED ON, LOGGED OFF, SHUTDOWN, and so on over a network.....
Posted: Fri Jun 15, 2007 9:08 am
by volka
Hm, still vague. What is a "LOGGED OFF" pc?
Posted: Fri Jun 15, 2007 9:18 am
by ghadacr
Basically what i'm not to sure about is whether PHP can connect to a PC and determine whether a PC is being used...
I have done it in Java, but not to sure how to do it in PHP, so i need some direction or a some example code....
Posted: Fri Jun 15, 2007 9:30 am
by volka
I have done it in Java, but not to sure how to do it in PHP
exactly what have you done in java? There is not "the" way to retrieve the information you want. You could have tried snmp or ldap or ... or ... so many possibilities.
Posted: Fri Jun 15, 2007 9:49 am
by ghadacr
That is all fine, but i need to get solution using PHP, so users can check whether a PC is available to use on a web based format...
Posted: Fri Jun 15, 2007 9:57 am
by volka
What did you do in java?
What technique did you use to get the information?
Was ist snmp?
If not, what was it?
Please tell me.
Can't help you without you telling me what you've done in java.
Because there is not "the" way to retrieve that information.
It kinda depends on what you have installed on the other pcs, i.e. what is available to collect the information you want.
Posted: Fri Jun 15, 2007 10:10 am
by ghadacr
What did you do in java? I used Java Sockets.(Java uses wide range of import functionality, so i utilised the import java.net.*; and
import java.io.*;
Basically i would specfic a port and ip address of the target PC, make a connection. Then if a successful connection was made it would output "user logged on", if there was no connection made because the target PC was off then i would output "PC Switched Off"....
Was ist snmp? I didnt use snmp protocol...
Posted: Fri Jun 15, 2007 10:14 am
by volka
meaning there is a "special" program running on the PCs you want to monitor?
A program that listens to a socket connection and then sends back the info you're looking for?
What program is it?
Posted: Fri Jun 15, 2007 10:20 am
by ghadacr
There is no "special" program, on the other machines, as i did not have any java classes on the other machine...
All the the java code did was output successful connections made to the target PC's.. As you dont need a program in the other machine to monitor for incoming socket connections. i didnt program it that way.
If i did it in Java RMI, that would be different.....
Posted: Fri Jun 15, 2007 10:32 am
by volka
ghadacr wrote:Basically i would specfic a port and ip address of the target PC, make a connection. Then if a successful connection was made it would output "user logged on", if there was no connection made because the target PC was off then i would output "PC Switched Off"....
Code: Select all
import java.net.Socket;
public class foobar {
public static void main(String[] args) {
// Basically i would specfic a port and ip address of the target PC
try {
// make a connection
Socket socket = new Socket("192.168.0.1", 21);
// Then if a successful connection was made it would output "user logged on"
System.out.println("user logged in");
}
catch(Exception e) {
// if there was no connection made because the target PC was off then i would output "PC Switched Off"....
System.out.println("PC Switched Off");
}
}
}
hm, this doesn't work. It's always telling me the PC is switched off.
What did you do?
Exactly what did you do?
Posted: Fri Jun 15, 2007 10:38 am
by ghadacr
Wait, wait....
This is a PHP forum not a Java, i came here for a anwser in PHP... Anyways the code you seem to have some errors in it... But i'm not going to discuss that...
If you cant do it then that is fine, thanks for your assitance...
Posted: Fri Jun 15, 2007 10:45 am
by volka
You right, I can't help you. Because you don't provide the necessary informations.
You gave me a (vague) description of what you did in java, I tried exactly that and guess what, it didn't work.
And please note the sarcasm.
Posted: Fri Jun 15, 2007 10:55 am
by ghadacr
LOL, LOL, LOL
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
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
Code: Select all
catch(Exception e) {
catch(Exception e) {
// if there was no connection made because the target PC was off then i would output "PC Switched Off"....
System.out.println("PC Switched Off");
Of course its not going to work, if you dont close the comments within the code....
Secondly you have to go into more detail about the specfic port numbers and IP address.....no error ouputting
All i ask for is some direction whether PHP incoprates network capabilties....