|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectp2ps.imp.endpoint.UDP.UDPEndpoint
A class that sends and receives message bytes to/from a Datagram Socket. If the message bytes exceed the packet size the message is split into multiple packets.
| Nested Class Summary | |
static class |
UDPEndpoint.DefaultInputMonitorFactory
|
| Field Summary | |
static int |
MAX_DATAGRAM_SIZE
|
static InputMonitorFactory |
monfactory
the input monitor factory |
static int |
RECEIVE_BUFFER_SIZE
|
static int |
SEND_BUFFER_SIZE
|
protected DatagramSocket |
socket
the socket data is sent to |
static int |
SOCKET_TIMEOUT
|
| Fields inherited from interface p2ps.imp.endpoint.UDP.UDPEndpointSchemes |
UDP_MULTICAST, UDP_STANDARD |
| Constructor Summary | |
|
UDPEndpoint(boolean input)
Creates a standard UDP socket for an available port |
|
UDPEndpoint(int port)
Creates a standard UDP socket for the specified port |
protected |
UDPEndpoint(java.lang.String scheme,
int port,
boolean input)
|
protected |
UDPEndpoint(UDPEndpoint udpsocket)
Creates a UDP socket based on an already existing socket |
| Method Summary | |
void |
addEndpointMessageListener(EndpointMessageListener listener)
Adds a listener to receive data from this endpoint |
void |
close()
Closes the socket |
java.net.URI |
getEndpointURI()
|
java.net.URI |
getSendURI()
|
DatagramSocket |
getSocket()
|
void |
handleMessage(DataMessage message,
java.net.SocketAddress replyaddr)
Called by a single input endpoint when a message is received. |
void |
init()
Initializes the socket |
protected void |
initSocket(int port,
boolean input)
Initialises the socket |
boolean |
isClosed()
|
boolean |
isInputEndpoint()
|
boolean |
isOutputEndpoint()
|
void |
removeEndpointMessageListener(EndpointMessageListener listener)
Removes a listener from this endpoint |
void |
send(byte[] message)
Sends a message from the endpoint to the address the endpoint is bound to, with no sendid. |
void |
send(java.lang.String sendid,
byte[] message)
Sends a message from the endpoint to the address the endpoint is bound to, along with the send id for this message. |
void |
send(java.lang.String sendid,
byte[] message,
java.net.SocketAddress addr)
Sends a message from the socket to the specified address |
void |
send(java.lang.String sendid,
byte[] message,
java.net.URI uri)
Sends a message from the socket to the specified address |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static int MAX_DATAGRAM_SIZE
public static int SEND_BUFFER_SIZE
public static int RECEIVE_BUFFER_SIZE
public static int SOCKET_TIMEOUT
public static InputMonitorFactory monfactory
protected DatagramSocket socket
| Constructor Detail |
public UDPEndpoint(boolean input)
throws java.io.IOException
public UDPEndpoint(int port)
throws java.io.IOException
protected UDPEndpoint(java.lang.String scheme,
int port,
boolean input)
throws java.io.IOException
protected UDPEndpoint(UDPEndpoint udpsocket)
| Method Detail |
protected void initSocket(int port,
boolean input)
throws java.io.IOException
java.io.IOExceptionpublic void init()
init in interface Endpointpublic void addEndpointMessageListener(EndpointMessageListener listener)
addEndpointMessageListener in interface Endpointpublic void removeEndpointMessageListener(EndpointMessageListener listener)
removeEndpointMessageListener in interface Endpointpublic DatagramSocket getSocket()
public java.net.URI getEndpointURI()
getEndpointURI in interface Endpointpublic java.net.URI getSendURI()
getSendURI in interface Endpointpublic boolean isInputEndpoint()
isInputEndpoint in interface Endpointpublic boolean isOutputEndpoint()
isOutputEndpoint in interface Endpoint
public void send(byte[] message)
throws java.io.IOException
send in interface Endpointjava.io.IOException
public void send(java.lang.String sendid,
byte[] message)
throws java.io.IOException
send in interface Endpointjava.io.IOException
public void send(java.lang.String sendid,
byte[] message,
java.net.URI uri)
throws java.io.IOException
java.io.IOException
public void send(java.lang.String sendid,
byte[] message,
java.net.SocketAddress addr)
throws java.io.IOException
java.io.IOException
public void handleMessage(DataMessage message,
java.net.SocketAddress replyaddr)
public void close()
throws java.io.IOException
close in interface Endpointjava.io.IOExceptionpublic boolean isClosed()
isClosed in interface Endpoint
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||