Example usage for org.apache.commons.validator.routines InetAddressValidator getInstance

List of usage examples for org.apache.commons.validator.routines InetAddressValidator getInstance

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines InetAddressValidator getInstance.

Prototype

public static InetAddressValidator getInstance() 

Source Link

Document

Returns the singleton instance of this validator.

Usage

From source file:pl.kotcrab.arget.server.ArgetClient.java

private void initSocket(String serverIp, int port) throws IOException {
    if (InetAddressValidator.getInstance().isValidInet4Address(serverIp) == false) {
        InetAddress address = InetAddress.getByName(serverIp);
        serverIp = address.getHostAddress();
    }//from   w w w.  j a va  2 s . c  om

    client = new Client(200000, 200000);
    KryoUtils.registerNetClasses(client.getKryo());
    client.start();

    sender = new ExchangeSender("Client Sender", client);
    pinger = new ExchangePinger(sender, "Client Pinger", new TimeoutListener() {
        @Override
        public void timedOut() {
            postStatus(ConnectionStatus.TIMEDOUT, "Server not responded to ping messages.");
            disconnect(false);
        }
    });

    client.connect(5000, serverIp, port);
    client.addListener(new Listener() {
        @Override
        public void received(Connection connection, Object object) {
            if (object instanceof Exchange) {
                Exchange exchange = (Exchange) object;
                processLater(exchange);
            }
        }
    });
}