⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.net

Class EchoUDPClient

java.lang.Object
|
+--org.apache.commons.net.DatagramSocketClient
   |
   +--org.apache.commons.net.DiscardUDPClient
      |
      +--org.apache.commons.net.EchoUDPClient


public final class EchoUDPClient
extends DiscardUDPClient

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.

Author:
Daniel F. Savarese
See Also:
EchoTCPClient
DiscardUDPClient

Field Summary

static int

DEFAULT_PORT

The default echo port.

Method Summary

int

receive(byte[] data, int length)

Receives echoed data and returns its length.

int

receive(byte[] data)

Same as receive(data, data.length) **

void

send(byte[] data, int length, InetAddress host)

Sends the specified data to the specified server at the default echo port.

void

send(byte[] data, InetAddress host)

Same as send(data, data.length, host) **

Field Details

DEFAULT_PORT

public static final int DEFAULT_PORT

The default echo port. It is set to 7 according to RFC 862. **

Method Details

receive

public int receive(byte[] data)

Same as receive(data, data.length) **

Parameters:
data

receive

public int receive(byte[] data, int length)

Receives echoed data and returns its length. The data may be divided up among multiple datagrams, requiring multiple calls to receive. Also, the UDP packets will not necessarily arrive in the same order they were sent.

Parameters:
data
length
Returns:
Length of actual data received.
Throws:
- If an error occurs while receiving the data.

send

public void send(byte[] data, InetAddress host)

Same as send(data, data.length, host) **

Parameters:
data
host

send

public void send(byte[] data, int length, InetAddress host)

Sends the specified data to the specified server at the default echo port.

Parameters:
data - The echo data to send.
length - The length of the data to send.
host - The address of the server.
Throws:
- If an error occurs during the datagram send operation.