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

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

Introduction

In this page you can find the example usage for org.apache.commons.net TimeUDPClient 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.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);/*  ww  w  .j a  va2s. c o m*/
    client.open();
    System.out.println(client.getDate(InetAddress.getByName(host)).toString());
    client.close();
}