Class NetworkHelper

java.lang.Object
net.simplace.core.service.NetworkHelper

public final class NetworkHelper extends Object
Network helper methods, e.g. scanning a subnet for open ports.
Author:
Andreas Enders
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Test entry point: scans the local subnet for open ports 22 and 80 and prints the result.
      Parameters:
      args - not used
      Throws:
      Exception - if the local network cannot be determined
    • 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 to System.out.
      Parameters:
      aPortsToScan - ports to probe on each address
      IpRangeToBeScanned - subnet in CIDR format xxx.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 resolved
      SocketException - 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