public final class EchoUDPClient extends DiscardUDPClient
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| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_PORT
The default echo port.
|
_isOpen_, _socket_, _socketFactory_, _timeout_| Constructor and Description |
|---|
EchoUDPClient() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
sendclose, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setSoTimeoutpublic static final int DEFAULT_PORT
public EchoUDPClient()
public int receive(byte[] data) throws IOException
receive(data, data.length)data - the buffer to receive the inputIOException - on errorpublic int receive(byte[] data, int length) throws IOException
data - the buffer to receive the inputlength - of the bufferIOException - If an error occurs while receiving the data.public void send(byte[] data, InetAddress host) throws IOException
send(data, data.length, host) send in class DiscardUDPClientdata - the buffer to sendhost - the target hostIOException - if an error occursDiscardUDPClient.send(byte[], int, InetAddress, int)public void send(byte[] data, int length, InetAddress host) throws IOException
send in class DiscardUDPClientdata - 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.DiscardUDPClient.send(byte[], int, InetAddress, int)Copyright © 2001–2022 The Apache Software Foundation. All rights reserved.