🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15323

Re: Performing a Ping

#15323
From: Sebastian
Date: Thu, 24 Jun 1999 00:00
46 lines
1987 bytes
as was stated,

port 7 is not a ping, rather the server simply echo's whatever you send to
it.  to write an "echo" service, and noting not all servers enable port 7
for echoing. do this,

   try {
       Socket s = new Socket("myHost", 7);
       DataInputStream dis = new DataInputStream(s.getInputStream());
       PrintStream pS = new PrintStream(s.getOutputStream());
       pS.println("Hello");
       String str = dis.readLine();
       if (str.equals("Hello")){
         msg = new Message();
         msg.setMessage("ECHO Reply Received: SERVER ALIVE");
         msg.setFrame(new Frame());
         msg.show();
         }
       else{
       msg = new Message();
         msg.setMessage("ECHO Reply Not Received: SERVER DEAD");
         msg.setFrame(new Frame());
         msg.show();
         }
       s.close();
       }
     catch (IOException e) {
       e.printStackTrace();
       }


note, for the connection to work, your applet (assuming you are using an
applet)) should be signed, if not, ask the client for permission, you will
however need netscape's capabilities class, then simply ask the client to
grant the "connect" permission on their worksation.


all should work, conditiontal on approtriate permission from the cleint.

"Klaus-F. Kaal" wrote:

> How can I send a ping from my Java-program? I tried a socket to port 7.
> That does not work.
>
> Thanks for help.
> Klaus
Technical Details
Message-ID: <37728C58.1036714C@ucalgary.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37515143.B3D8D4C0@debis.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,6f104456fd230143
X-Google-Attributes: gidf74b3,public
From: Sebastian <smaurice@ucalgary.ca>
Subject: Re: Performing a Ping
Date: 1999/06/24
Message-ID: <37728C58.1036714C@ucalgary.ca>
X-Deja-AN: 493492783
Content-Transfer-Encoding: 7bit
References: <37515143.B3D8D4C0@debis.com>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language