Example usage for org.apache.commons.net DaytimeUDPClient DaytimeUDPClient

List of usage examples for org.apache.commons.net DaytimeUDPClient DaytimeUDPClient

Introduction

In this page you can find the example usage for org.apache.commons.net DaytimeUDPClient DaytimeUDPClient.

Prototype

DaytimeUDPClient

Source Link

Usage

From source file:examples.daytime.java

public static final void daytimeUDP(String host) throws IOException {
    DaytimeUDPClient client = new DaytimeUDPClient();

    // We want to timeout if a response takes longer than 60 seconds
    client.setDefaultTimeout(60000);/*from   ww  w  .ja va2  s  .com*/
    client.open();
    System.out.println(client.getTime(InetAddress.getByName(host)).trim());
    client.close();
}

From source file:ProtocolRunner.java

public static DatagramSocketClient getUDPClientInstance(int clientType) {
   switch(clientType) {
        case 0: { // is chargen
            if(charGenUDPClient == null) {
                charGenUDPClient = new CharGenUDPClient();
            }/* w  w  w. j  a  v a2s.  co m*/
            return charGenUDPClient;
        }
       case 1: { // is daytime
           if(daytimeUDPClient == null) {
               daytimeUDPClient = new DaytimeUDPClient();
           }
           return daytimeUDPClient;
       }
       case 2: { // is echo
           if(echoUDPClient == null) {
               echoUDPClient = new EchoUDPClient();
           }
           return echoUDPClient;
       }
       case 3: { // is tftp
           if(tftpClient == null) {
               tftpClient = new TFTPClient();
           }
           return tftpClient;
       }
       case 4: { // is time
           if(timeUDPClient == null) {
               timeUDPClient = new TimeUDPClient();
           }
           return timeUDPClient;
       }
    }
   return null;
}