|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jarol.messages.Link jarol.messages.UDPLink
public class UDPLink
UDP socket message link.
This message link allows simple bi-directional communication between UDP ports. The local host will listen on a specified local port for messages and send messages to a specified UDP port on a remote host.
Field Summary |
---|
Fields inherited from class jarol.messages.Link |
---|
DEFAULT_PORT_BUFSZ, MAX_MESSAGE_PAYLOAD |
Constructor Summary | |
---|---|
UDPLink(MessageFactory factory,
java.lang.String host,
int localPort,
int remotePort)
Constructor. |
|
UDPLink(MessageFactory factory,
java.lang.String host,
int localPort,
int remotePort,
int recvBufSz,
int sendBufSz)
Constructor with specified receive / send buffer size. |
Method Summary | |
---|---|
protected int |
recv(byte[] buf,
int off,
int len,
int timeout)
Receive data. |
protected void |
send(byte[] data,
int off,
int len)
Send data to the remote UDP socket. |
protected void |
start()
Start the UDP link. |
protected void |
stop()
Stop the UDP link. |
Methods inherited from class jarol.messages.Link |
---|
connect, connected, disconnect, getRecvPort, getSendPort, getSendSignal |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UDPLink(MessageFactory factory, java.lang.String host, int localPort, int remotePort) throws java.net.UnknownHostException
factory
- the message factory to usehost
- host name or IP addresslocalPort
- local UDP portremotePort
- remote UDP port
java.net.UnknownHostException
- as described in InetAddress.getByName()public UDPLink(MessageFactory factory, java.lang.String host, int localPort, int remotePort, int recvBufSz, int sendBufSz) throws java.net.UnknownHostException
factory
- the message factory to usehost
- host name or IP addresslocalPort
- local UDP portremotePort
- remote UDP portrecvBufSz
- receive buffer sizesendBufSz
- send buffer size
java.net.UnknownHostException
- as described in InetAddress.getByName()Method Detail |
---|
protected void start() throws java.io.IOException
This will set up the UDP datagram socket listening onto the local UDP port.
start
in class Link
java.io.IOException
- if an error occurs creating the socket.protected void stop() throws java.io.IOException
This will close the UDP datagram socket.
stop
in class Link
java.io.IOException
- if an error occurs closing the socket.protected int recv(byte[] buf, int off, int len, int timeout) throws java.io.IOException
recv
in class Link
buf
- read bufferoff
- read buffer offsetlen
- read buffer usable lengthtimeout
- timeout for receive
java.io.IOException
- if a network error occursprotected void send(byte[] data, int off, int len) throws java.io.IOException
send
in class Link
data
- data bufferoff
- data buffer offsetlen
- data buffer usable length
java.io.IOException
- if a network error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |