|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.net.DatagramSocketClient org.apache.commons.net.DiscardUDPClient org.apache.commons.net.EchoUDPClient
public final class EchoUDPClient
The EchoUDPClient class is a UDP implementation of a client for the
Echo protocol described in RFC 862. To use the class,
just open a local UDP port
with open
and call send
to send datagrams to the server,
then call receive
to receive echoes.
After you're done echoing data, call
close()
to clean up properly.
EchoTCPClient
,
DiscardUDPClient
Field Summary | |
---|---|
static int |
DEFAULT_PORT
The default echo port. |
Fields inherited from class org.apache.commons.net.DatagramSocketClient |
---|
_isOpen_, _socket_, _socketFactory_, _timeout_ |
Constructor Summary | |
---|---|
EchoUDPClient()
|
Method Summary | |
---|---|
int |
receive(byte[] data)
Same as receive(data, data.length) |
int |
receive(byte[] data,
int length)
Receives echoed data and returns its length. |
void |
send(byte[] data,
InetAddress host)
Same as send(data, data.length, host) |
void |
send(byte[] data,
int length,
InetAddress host)
Sends the specified data to the specified server at the default echo port. |
Methods inherited from class org.apache.commons.net.DiscardUDPClient |
---|
send |
Methods inherited from class org.apache.commons.net.DatagramSocketClient |
---|
close, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setDatagramSocketFactory, setDefaultTimeout, setSoTimeout |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_PORT
Constructor Detail |
---|
public EchoUDPClient()
Method Detail |
---|
public void send(byte[] data, int length, InetAddress host) throws IOException
send
in class DiscardUDPClient
data
- The echo data to send.length
- The length of the data to send. Should be less than
or equal to the length of the data byte array.host
- The address of the server.
IOException
- If an error occurs during the datagram send
operation.public void send(byte[] data, InetAddress host) throws IOException
send(data, data.length, host)
send
in class DiscardUDPClient
IOException
public int receive(byte[] data, int length) throws IOException
IOException
- If an error occurs while receiving the data.public int receive(byte[] data) throws IOException
receive(data, data.length)
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |