public interface ConnectionServer
This interface should be implemented by classes that wish to
act as connection servers and to accept requests from
ConnectionClient
objects.
The server can call request()
to allow a client
to establish a connection to the server and to obtain the client's
initial request. This should block until a client establishes a
connection.
Once a request has been received, the server should reply to the client.
If the server wants to close the connection then the server should call
replyAndClose(Object)
or alternatively
reply(Object, boolean)
with the boolean
set to
true
. If the server wants to keep the connection open, then it
should call reply(Object)
or alternatively
reply(Object, boolean)
with the boolean
set to
false
. The reply(Object, boolean)
method is
provided for convenience in closing connections programatically.
Modifier and Type | Field and Description |
---|---|
static StandardChannelFactory |
FACTORY
The factory for creating channels within servers.
|
Modifier and Type | Method and Description |
---|---|
void |
reply(Object data)
Sends some data back to the client after a request
has been received but keeps the connection open.
|
void |
reply(Object data,
boolean close)
Sends some data back to the client after a request
has been received.
|
void |
replyAndClose(Object data)
Sends some data back to the client and closes the connection.
|
Object |
request()
Receives a request from a client.
|
static final StandardChannelFactory FACTORY
Object request() throws IllegalStateException
Receives a request from a client. This will block until the client
calls its request(Object)
method. Implementations may
make this ALTable.
After this method has returned, the server should call one of the reply methods. Performing any external process synchronization between these method calls could be potentially hazardous and could lead to deadlock.
Object
sent by the client.IllegalStateException
void reply(Object data) throws IllegalStateException
Sends some data back to the client after a request
has been received but keeps the connection open. After calling
this method, the server should call recieve()
to receive a further request.
A call to this method is equivalent to a call to
reply(Object, boolean)
with the boolean set to
false
.
data
- the data to send to the client.IllegalStateException
void reply(Object data, boolean close)
Sends some data back to the client after a request
has been received. The boolean
close parameter
indicates whether the connection should be closed after this
reply has been sent.
This method should not block.
data
- the data to send back to client.close
- boolean
that should be true
iff the connection should be dropped after the reply
has been sent.void replyAndClose(Object data) throws IllegalStateException
Sends some data back to the client and closes the connection.
A call to this method is equivalent to a call to
reply(Object, boolean)
with the boolean set to
true
.
data
- the data to send back to client.IllegalStateException
Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.