Keywords: NetworkServerControl class, NetworkServerControl API, NetworkServerControl class and

# Using the NetworkServerControl API

You need to create an instance of the NetworkServerControl class if you are using the API. There are two constructor methods for this class:

Note: Before enabling connections from other systems, ensure that you are running under security manager.

- NetworkServerControl()

  This constructor method creates an instance that listens either on the default port (1527) or the port that is set by the `derby.drda.portNumber` property. It will also listen on the host set by the `derby.drda.host` property or the loopback address if the property is not set. This is the default constructor; it does not allow remote connections. It is equivalent to calling NetworkServerControl(InetAddress.getByName("localhost"),1527) if no properties are set.

- NetworkServerControl (InetAddress address, int portNumber)
  This constructor method creates an instance that listens on the specified `portNumber` on the specified address. The `InetAddress` will be passed to `ServerSocket`. NULL is an invalid address value. The following examples show how you might allow Network Server to accept connections from other hosts:

      //accepts connections from other hosts on an IPv4 system
      NetworkServerControl serverControl =
        new NetworkServerControl(InetAddress.getByName("0.0.0.0"),1527);

      //accepts connections from other hosts on an IPV6 system
      NetworkServerControl serverControl =
        new NetworkServerControl(InetAddress.getByName("::"),1527);

Parent topic: Overview