|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

public interface IEndpoint
An endpoint, which can be used to send and receive UserDatagram. E.g.
// without datagram handler
...
IEndpoint endpoint = new Endpoint(packageSize);
UserDatagram request = new UserDatagram(remoteHostname, remotePort, packageSize);
request.write("Hello peer, how are you?");
endpoint.send(request);
UserDatagram response = endpoint.receive(1000); // receive (timeout 1 sec)
endpoint.close();
...
// by using a handler
...
MyHandler hdl = new MyHandler();
IEndpoint endpoint = new Endpoint(packageSize, hdl);
UserDatagram request = new UserDatagram(remoteHostname, remotePort, packageSize);
request.write("Hello peer, how are you?");
endpoint.send(request);
// response will be handled by MyHandler
// wait
...
endpoint.close();
class MyHandler implements IDatagramHandler {
public boolean onDatagram(IEndpoint localEndpoint) throws IOException {
UserDatagram datagram = localEndpoint.receive(); // get the datagram
...
return true;
}
}
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_HOST_ADDRESS
the default host address |
static java.lang.String |
IP_MULTICAST_LOOP
|
static java.lang.String |
IP_MULTICAST_TTL
|
static java.lang.String |
IP_TOS
|
static java.lang.String |
SO_BROADCAST
|
static java.lang.String |
SO_RCVBUF
|
static java.lang.String |
SO_REUSEADDR
|
static java.lang.String |
SO_SNDBUF
|
| Method Summary | |
|---|---|
java.lang.String |
getDefaultEncoding()
gets the default encoding used by this endpoint |
java.lang.String |
getId()
return the endpoint id |
java.net.InetAddress |
getLocalAddress()
returns the address of the endpoint |
int |
getLocalPort()
returns the port of the endpoint |
java.net.SocketAddress |
getLocalSocketAddress()
Deprecated. |
java.lang.Object |
getOption(java.lang.String name)
returns the vlaue of a option |
java.util.Map<java.lang.String,java.lang.Class> |
getOptions()
Returns an unmodifiable map of the options supported by this endpont. |
int |
getReceiveSize()
get the size of the datagram that will be received |
boolean |
isOpen()
returns, if the endpoint is open |
UserDatagram |
receive()
receive a datagram packet (receive timeout = 0) |
UserDatagram |
receive(long timeoutMillis)
receive a datagram packet |
void |
send(UserDatagram datagram)
send a datagram to the remote endpoint |
void |
setDefaultEncoding(java.lang.String encoding)
sets the default encoding used by this endpoint |
void |
setReceiveSize(int receiveSize)
set the size of the datagram that will be received |
void |
setWorkerPool(IWorkerPool workerPool)
Deprecated. |
| Methods inherited from interface java.io.Closeable |
|---|
close |
| Field Detail |
|---|
static final java.lang.String SO_SNDBUF
static final java.lang.String SO_RCVBUF
static final java.lang.String SO_REUSEADDR
static final java.lang.String SO_BROADCAST
static final java.lang.String IP_TOS
static final java.lang.String IP_MULTICAST_TTL
static final java.lang.String IP_MULTICAST_LOOP
static final java.lang.String DEFAULT_HOST_ADDRESS
| Method Detail |
|---|
boolean isOpen()
java.net.SocketAddress getLocalSocketAddress()
java.net.InetAddress getLocalAddress()
int getLocalPort()
void setDefaultEncoding(java.lang.String encoding)
encoding - the default encodingjava.lang.String getDefaultEncoding()
void send(UserDatagram datagram)
throws java.io.IOException
datagram - the datagram to send
java.io.IOException - If some other I/O error occurs
ClosedConnectionException - if the underlying channel is closedvoid setReceiveSize(int receiveSize)
receiveSize - the receive sizeint getReceiveSize()
UserDatagram receive()
throws java.io.IOException
java.io.IOException - If some other I/O error occurs
UserDatagram receive(long timeoutMillis)
throws java.io.IOException,
java.net.SocketTimeoutException
timeoutMillis - the receive timeout in millis
java.net.SocketTimeoutException - If the receive timeout has been reached
java.io.IOException - If some other I/O error occursvoid setWorkerPool(IWorkerPool workerPool)
java.lang.String getId()
java.lang.Object getOption(java.lang.String name)
throws java.io.IOException
name - the name of the option
java.io.IOException - In an I/O error occursjava.util.Map<java.lang.String,java.lang.Class> getOptions()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||