Class NetworkHelper
java.lang.Object
net.simplace.core.service.NetworkHelper
Network helper methods, e.g. scanning a subnet for open ports.
- Author:
- Andreas Enders
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidTest entry point: scans the local subnet for open ports 22 and 80 and prints the result.requestSimplaceServerState(InetSocketAddress inetSocketAddress) Requests the state of a SIMPLACE server.static final List<InetSocketAddress> scanPortOpened(Integer[] aPortsToScan, String IpRangeToBeScanned) Scans all addresses of a subnet for open TCP ports.
-
Method Details
-
main
-
scanPortOpened
public static final List<InetSocketAddress> scanPortOpened(Integer[] aPortsToScan, String IpRangeToBeScanned) throws UnknownHostException, SocketException Scans all addresses of a subnet for open TCP ports. Each address/port combination is probed in parallel (20 threads) with a connect timeout of 200 ms. The number of open ports found is printed toSystem.out.- Parameters:
aPortsToScan- ports to probe on each addressIpRangeToBeScanned- subnet in CIDR formatxxx.xxx.xxx.xxx/yy; if empty, the subnet of the local host is scanned- Returns:
- one socket address for each address/port combination that accepted a connection
- Throws:
UnknownHostException- if the local host cannot be resolvedSocketException- if the network interface of the local host cannot be determined
-
requestSimplaceServerState
public static HashMap<String,Object> requestSimplaceServerState(InetSocketAddress inetSocketAddress) Requests the state of a SIMPLACE server. Not implemented yet.- Parameters:
inetSocketAddress- address of the server- Returns:
- always
null
-