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

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

Introduction

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

Prototype

TimeUDPClient

Source Link

Usage

From source file:examples.rdate.java

public static final void timeUDP(String host) throws IOException {
    TimeUDPClient client = new TimeUDPClient();

    // We want to timeout if a response takes longer than 60 seconds
    client.setDefaultTimeout(60000);/*from w  w w .  j  av  a  2 s . co m*/
    client.open();
    System.out.println(client.getDate(InetAddress.getByName(host)).toString());
    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();
            }// ww w. j  a  v  a 2 s .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;
}