Package org.jcsp.lang

# Class SharedConnectionServerImpl

java.lang.Object
org.jcsp.lang.SharedConnectionServerImpl

All Implemented Interfaces:
  `ConnectionServer`, `SharedConnectionServer`

public class SharedConnectionServerImpl extends Object implements SharedConnectionServer
This class does not need to be used by standard JCSP users. It is exposed so that the connection mechanism can be extended for custom connections.

Author:
  Quickstone Technologies Limited

## Field Summary

### Fields inherited from interface org.jcsp.lang.ConnectionServer

`FACTORY`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SharedConnectionServerImpl(AltingChannelInput openIn, AltingChannelInput requestIn, ChannelInput synchIn, SharedChannelOutput synchOut, org.jcsp.lang.ConnectionWithSharedAltingServer parent)`

## Method Summary

Modifier and Type
Method
Description
`SharedConnectionServer`
`duplicate()`
Creates a duplicate copy of the connection end.
`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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SharedConnectionServerImpl

protected SharedConnectionServerImpl(AltingChannelInput openIn, AltingChannelInput requestIn, ChannelInput synchIn, SharedChannelOutput synchOut, org.jcsp.lang.ConnectionWithSharedAltingServer parent)

## Method Details

### request

public Object request()
Description copied from interface: `ConnectionServer`

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.

Specified by:
  `request` in interface `ConnectionServer`
Returns:
  the `Object` sent by the client.

### reply

public void reply(Object data)
Description copied from interface: `ConnectionServer`

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`.

Specified by:
  `reply` in interface `ConnectionServer`
Parameters:
  `data` - the data to send to the client.

### reply

public void reply(Object data, boolean close)
Description copied from interface: `ConnectionServer`

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.

Specified by:
  `reply` in interface `ConnectionServer`
Parameters:
  `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.

### replyAndClose

public void replyAndClose(Object data)
Description copied from interface: `ConnectionServer`

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`.

Specified by:
  `replyAndClose` in interface `ConnectionServer`
Parameters:
  `data` - the data to send back to client.

### duplicate

public SharedConnectionServer duplicate()
Description copied from interface: `SharedConnectionServer`

Creates a duplicate copy of the connection end.

Specified by:
  `duplicate` in interface `SharedConnectionServer`
Returns:
  the duplicate `SharedConnectionServer` object.