| The CharGenUDPClient class is a UDP implementation of a client for the
character generator protocol described in RFC 864. It can also be
used for Systat (RFC 866), Quote of the Day (RFC 865), and netstat
(port 15). All of these protocols involve sending a datagram to the
appropriate port, and reading data contained in one or more reply
datagrams. The chargen and quote of the day protocols only send
one reply datagram containing 512 bytes or less of data. The other
protocols may reply with more than one datagram, in which case you
must wait for a timeout to determine that all reply datagrams have
been sent.
To use the CharGenUDPClient class, just open a local UDP port
with
org.apache.commons.net.DatagramSocketClient.open open and call
CharGenUDPClient.send send to send the datagram that will
initiate the data reply. For chargen or quote of the day, just
call
CharGenUDPClient.receive receive , and you're done. For netstat and
systat, call receive in a while loop, and catch a SocketException and
InterruptedIOException to detect a timeout (don't forget to set the
timeout duration beforehand). Don't forget to call
org.apache.commons.net.DatagramSocketClient.close close() to clean up properly.
author: Daniel F. Savarese See Also: CharGenTCPClient |