public class Server extends Object implements AutoCloseable
Socket-based Server that can
handle, using OperationHandlers, Operations invoked by
Clients.Client,
Operation,
OperationHandler| Modifier and Type | Field and Description |
|---|---|
static Operation<Void> |
CLOSE_OPERATION
Special operation to signal the server that the client has been closed.
|
static Logger |
LOG
Logger
|
| Constructor and Description |
|---|
Server(int port)
|
| Modifier and Type | Method and Description |
|---|---|
void |
addOperationHandler(OperationHandler handler)
Registers the specified
OperationHandler for an operation. |
void |
close()
Stops the
Server. |
InetAddress |
getInetAddress()
Obtains the
InetAddress on which the Server is listening. |
int |
getPort()
Obtains the port on which the
Server is listening. |
InetAddress |
open()
Opens and starts the
Server. |
public static final Logger LOG
public Server(int port)
port - the port on which to accept Client connections and requestspublic void addOperationHandler(OperationHandler handler)
OperationHandler for an operation.handler - the OperationHandlerpublic InetAddress open() throws IOException
InetAddress on which the Server
is accepting requests from Clients.IOException - if not able to create ServerSocketpublic InetAddress getInetAddress()
InetAddress on which the Server is listening.InetAddresspublic int getPort()
Server is listening.public void close()
close in interface AutoCloseableCopyright © 2019. All rights reserved.