FileDocCategorySizeDatePackage
HeartBeat.javaAPI DocExample747Sun Jul 06 18:13:14 BST 1997None

HeartBeat

public class HeartBeat extends Applet

Fields Summary
String
myHost
int
myPort
Constructors Summary
Methods Summary
public voidinit()

		myHost = getCodeBase().getHost();
		myPort = Integer.parseInt( getParameter("myPort") );
	
private voidsendMessage(java.lang.String message)

		try {
			byte [] data = message.getBytes();
			InetAddress addr = InetAddress.getByName( myHost );
			DatagramPacket pack = 
				new DatagramPacket(data, data.length, addr, myPort );
			DatagramSocket ds = new DatagramSocket();
			ds.send( pack );
			ds.close();
		} catch ( IOException e ) {
			System.out.println( e );  // Error creating socket
		}
	
public voidstart()

		sendMessage("Arrived");
	
public voidstop()

		sendMessage("Departed");