FileDocCategorySizeDatePackage
UDPDaytimeServer.javaAPI DocExample600Thu Apr 03 15:25:42 BST 1997None

UDPDaytimeServer.java

import java.net.*;
import java.io.*;
import java.util.Date;

public class UDPDaytimeServer extends UDPServer {

  protected static int defaultPort = 13;
 
  public static void respond(DatagramSocket ds, DatagramPacket dp) {

    DatagramPacket outgoing;
    
    Date now = new Date();
    String s = now.toString();
    byte[] data = new byte[s.length()];
    s.getBytes(0, s.length(), data, 0);
    try {
      outgoing = new DatagramPacket(data, data.length, dp.getAddress(), dp.getPort());
      ds.send(outgoing);
    }
    catch (IOException e) {
      System.err.println(e);
    }
    
  }

}