import java.net.*; public class OnLineTermAmy extends Thread { private final int SENDER_SLEEP_TIME = 1000; private String name = "Amy"; private String comment = "Hi_all!"; private int port = 2000; private String address = "234.235.236.237"; public static void main(String[] args) { new OnLineTermAmy(); } public OnLineTermAmy() { //setDaemon(true); start(); } public void run() { MulticastSocket ms = null; try { ms = new MulticastSocket(); ms.setTimeToLive(0); //ms.setInterface(InetAddress.getByName("localhost")); } catch(Exception e) {} while(true) { try { sleep(SENDER_SLEEP_TIME); String message = "From: " + name + " Host: " + InetAddress.getLocalHost().toString() + " Comment: " + comment; byte[] data = message.getBytes(); DatagramPacket packet = new DatagramPacket(data, data.length, InetAddress.getByName(address), port); ms.send(packet); } catch(Exception e) {} } } }