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

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

Introduction

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

Prototype

public void open() throws SocketException 

Source Link

Document

Opens a DatagramSocket on the local host at the first available 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);//from w w w  . j  a  va  2 s.c om
    client.open();
    System.out.println(client.getTime(InetAddress.getByName(host)).trim());
    client.close();
}