Package org.apache.commons.net.echo
Class EchoUDPClient
java.lang.Object
org.apache.commons.net.DatagramSocketClient
org.apache.commons.net.discard.DiscardUDPClient
org.apache.commons.net.echo.EchoUDPClient
- All Implemented Interfaces:
- AutoCloseable
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.- See Also:
- 
Field SummaryFieldsFields inherited from class org.apache.commons.net.DatagramSocketClient_isOpen_, _socket_, _socketFactory_, _timeout_
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintreceive(byte[] data) Same asreceive(data, data.length)intreceive(byte[] data, int length) Receives echoed data and returns its length.voidsend(byte[] data, int length, InetAddress host) Sends the specified data to the specified server at the default echo port.voidsend(byte[] data, InetAddress host) Same assend(data, data.length, host)Methods inherited from class org.apache.commons.net.discard.DiscardUDPClientsendMethods inherited from class org.apache.commons.net.DatagramSocketClientcheckOpen, close, getCharset, getCharsetName, getDefaultTimeout, getLocalAddress, getLocalPort, getSoTimeout, getSoTimeoutDuration, isOpen, open, open, open, setCharset, setDatagramSocketFactory, setDefaultTimeout, setDefaultTimeout, setSoTimeout, setSoTimeout
- 
Field Details- 
DEFAULT_PORTThe default echo port. It is set to 7 according to RFC 862.- See Also:
 
 
- 
- 
Constructor Details- 
EchoUDPClientpublic EchoUDPClient()
 
- 
- 
Method Details- 
receiveSame asreceive(data, data.length)- Parameters:
- data- the buffer to receive the input
- Returns:
- the number of bytes
- Throws:
- IOException- on error
 
- 
receiveReceives 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- the buffer to receive the input
- length- of the buffer
- Returns:
- Length of actual data received.
- Throws:
- IOException- If an error occurs while receiving the data.
 
- 
sendSame assend(data, data.length, host)- Overrides:
- sendin class- DiscardUDPClient
- Parameters:
- data- the buffer to send
- host- the target host
- Throws:
- IOException- if an error occurs
- See Also:
 
- 
sendSends the specified data to the specified server at the default echo port.- Overrides:
- sendin class- DiscardUDPClient
- Parameters:
- 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.
- Throws:
- IOException- If an error occurs during the datagram send operation.
- See Also:
 
 
-