Nebula
01-29-2003, 05:31 PM
I have an idea for something to code in Java, but I would like to know how (if possible) to ping a remote server. Â*I'd normally do this in PHP, since it will be serving out webpages, but I'd like the user to see the ping from the users computer to the target server, instead of MY server to the target. Â*So, I decided Java, since I'm pretty sure JavaScript can't cut it.
I read somewhere you can't do a IMCP ping in Java, because it doesn't allow raw sockets. Â*Even if you can't, I'd imagine you could do something like just start a timer, open a socket to port 80 on the server (the servers being pinged WILL have a HTTP daemon running, so don't worry about port 80 being closed), and then after the connection is opened, stop the timer, and see how many miliseconds have passed, and then close the socket without retrieving or sending any data. Â*If you have other port number suggestions, or whatever (or more importantly, suggestions on how to do this), please reply. Â*I have a pretty basic understanding of Swing, but I have no clue about any of the networking/internet sides of Java (hence why I'll be taking the advanced Java class in session 2 this year http://campcaen.engin.umich.edu/iB_html/non-cgi/emoticons/wink.gif).
Thanks a bunch for any help.
I read somewhere you can't do a IMCP ping in Java, because it doesn't allow raw sockets. Â*Even if you can't, I'd imagine you could do something like just start a timer, open a socket to port 80 on the server (the servers being pinged WILL have a HTTP daemon running, so don't worry about port 80 being closed), and then after the connection is opened, stop the timer, and see how many miliseconds have passed, and then close the socket without retrieving or sending any data. Â*If you have other port number suggestions, or whatever (or more importantly, suggestions on how to do this), please reply. Â*I have a pretty basic understanding of Swing, but I have no clue about any of the networking/internet sides of Java (hence why I'll be taking the advanced Java class in session 2 this year http://campcaen.engin.umich.edu/iB_html/non-cgi/emoticons/wink.gif).
Thanks a bunch for any help.