Example usage for org.apache.commons.net.time TimeTCPClient setDefaultPort

List of usage examples for org.apache.commons.net.time TimeTCPClient setDefaultPort

Introduction

In this page you can find the example usage for org.apache.commons.net.time TimeTCPClient setDefaultPort.

Prototype

public void setDefaultPort(int port) 

Source Link

Document

Sets the default port the SocketClient should connect to when a port is not specified.

Usage

From source file:it.jnrpe.plugin.CheckTime.java

private Date getTimeTCP(String host, int timeout, int port) throws IOException {
    TimeTCPClient client = new TimeTCPClient();
    client.setDefaultPort(port);
    client.setDefaultTimeout((int) TimeUnit.SECOND.convert(timeout));
    client.connect(host);//ww w. java  2s.  c om
    Date date = client.getDate();
    client.disconnect();
    return date;

}