Interface NetworkServer

All Superinterfaces:
AutoCloseable, NetworkComponent, PacketSender

public interface NetworkServer extends NetworkComponent, AutoCloseable
Represents a network component which can accept connection from other network components within the network.
Since:
4.0
  • Method Details

    • addListener

      @NonNull @NonNull CompletableFuture<Void> addListener(int port)
      Binds this network server to the given port on any local address (ipv6 form: ::/0) if no other listener is already listening to that port.
      Parameters:
      port - the port to which the listener should get bound.
      Returns:
      a future completed exceptionally if the bind fails, normally if the bind succeeded.
      Throws:
      IllegalArgumentException - if the given port exceeds the port range.
    • addListener

      Binds this network server to the given host and port if no listener is already listening on the given address.
      Parameters:
      hostAndPort - the address to which a listener should get bound.
      Returns:
      a future completed exceptionally if the bind fails, normally if the bind succeeded.
      Throws:
      NullPointerException - if the given host and port is null.