public class Server extends Object implements AutoCloseable
Socket
-based Server
that can
handle, using OperationHandler
s, Operation
s invoked by
Client
s.Client
,
Operation
,
OperationHandler
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 Server(int port)
port
- the port on which to accept Client
connections and requestspublic void addOperationHandler(OperationHandler handler)
OperationHandler
for an operation.handler
- the OperationHandler
public InetAddress open() throws IOException
InetAddress
on which the Server
is accepting requests from Client
s.IOException
public InetAddress getInetAddress()
InetAddress
on which the Server
is listening.InetAddress
public int getPort()
Server
is listening.public void close()
close
in interface AutoCloseable
Copyright © 2014. All Rights Reserved.