Interface NetworkServer
- All Superinterfaces:
AutoCloseable, NetworkComponent, PacketSender
Represents a network component which can accept connection from other network components within the network.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionaddListener(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.addListener(@NonNull HostAndPort hostAndPort) Binds this network server to the given host and port if no listener is already listening on the given address.Methods inherited from interface AutoCloseable
closeMethods inherited from interface NetworkComponent
channels, closeChannels, firstChannel, packetDispatcher, packetRegistry, sslEnabledMethods inherited from interface PacketSender
sendPacket, sendPacket, sendPacketSync
-
Method Details
-
addListener
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.
-