Package com.aoapps.messaging.tcp.server
Class TcpSocketServer
java.lang.Object
com.aoapps.messaging.base.AbstractSocketContext<TcpSocket>
com.aoapps.messaging.tcp.server.TcpSocketServer
- All Implemented Interfaces:
com.aoapps.messaging.SocketContext
,Closeable
,AutoCloseable
Server component for bi-directional messaging over TCP.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.aoapps.messaging.base.AbstractSocketContext
AbstractSocketContext.IdentifierAvailabilityChecker
-
Constructor Summary
ConstructorDescriptionTcpSocketServer
(int port) Creates a new TCP socket server.TcpSocketServer
(int port, int backlog) Creates a new TCP socket server.TcpSocketServer
(int port, int backlog, InetAddress bindAddr) Creates a new TCP socket server. -
Method Summary
Methods inherited from class com.aoapps.messaging.base.AbstractSocketContext
addIdentifierAvailabilityChecker, addSocket, addSocketContextListener, callOnError, getSocket, getSockets, isClosed, newIdentifier, removeIdentifierAvailabilityChecker, removeSocketContextListener
-
Constructor Details
-
TcpSocketServer
public TcpSocketServer(int port) Creates a new TCP socket server. -
TcpSocketServer
public TcpSocketServer(int port, int backlog) Creates a new TCP socket server. -
TcpSocketServer
Creates a new TCP socket server.
-
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfacecom.aoapps.messaging.SocketContext
- Overrides:
close
in classAbstractSocketContext<TcpSocket>
-
start
public void start(Callback<? super TcpSocketServer> onStart, Callback<? super Throwable> onError) throws IllegalStateException Starts the I/O of a socket server. After creation, a socket server does not accept connections until started. This allows listeners to be registered between creation and start call.- Throws:
IllegalStateException
- if closed or already started
-