Package org.kiwiproject.net
Class SocketChecker
java.lang.Object
org.kiwiproject.net.SocketChecker
Utilities for checking sockets.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanConnectViaSocket(String host, int port) Check whether aSocketcan be opened on the specified host and port.booleancanConnectViaSocket(String host, int port, Duration timeout) Check whether aSocketcan be opened on the specified host and port, with the specified timeout.booleancanConnectViaSocket(org.apache.commons.lang3.tuple.Pair<String, Integer> hostAndPort) Check whether aSocketcan be opened on the specified host and port.booleancanConnectViaSocket(org.apache.commons.lang3.tuple.Pair<String, Integer> hostAndPort, Duration timeout) Check whether aSocketcan be opened on the specified host and port, with the specified timeout.
-
Field Details
-
DEFAULT_TIMEOUT
-
-
Constructor Details
-
SocketChecker
public SocketChecker()
-
-
Method Details
-
canConnectViaSocket
Check whether aSocketcan be opened on the specified host and port.- Parameters:
host- the host to checkport- the port to check- Returns:
trueif the port is open;falseotherwise
-
canConnectViaSocket
Check whether aSocketcan be opened on the specified host and port, with the specified timeout.- Parameters:
host- the host to checkport- the port to checktimeout- how long to wait for the socket connection before timing out- Returns:
trueif the socket connection succeeded;falseotherwise
-
canConnectViaSocket
Check whether aSocketcan be opened on the specified host and port. Uses the default timeout ofDEFAULT_TIMEOUT.- Parameters:
hostAndPort- a Pair containing the host and port to check- Returns:
trueif the socket connection succeeded;falseotherwise
-
canConnectViaSocket
public boolean canConnectViaSocket(org.apache.commons.lang3.tuple.Pair<String, Integer> hostAndPort, Duration timeout) Check whether aSocketcan be opened on the specified host and port, with the specified timeout.- Parameters:
hostAndPort- a Pair containing the host and port to checktimeout- how long to wait for the socket connection before timing out- Returns:
trueif the socket connection succeeded;falseotherwise
-