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

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

Introduction

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

Prototype

public String getTime(InetAddress host) throws IOException 

Source Link

Document

Same as getTime(host, DaytimeUDPClient.DEFAULT_PORT);

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);// www .j a v a 2s.c  o  m
    client.open();
    System.out.println(client.getTime(InetAddress.getByName(host)).trim());
    client.close();
}

From source file:ProtocolRunner.java

private static void handleUDPDaytime(
    DaytimeUDPClient client, ProtocolRunner runner) 
    throws IOException {            
        runner.getUDPServerResponse().append(
            client.getTime(
                InetAddress.getByName(runner.getUDPRemoteServer())) 
                + "\r\n");
}