* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
To use the CharGenUDPClient class, just open a local UDP port
send to send the datagram that will
initiate the data reply. For chargen or quote of the day, just
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
to clean up properly.
// CharGen return packets have a maximum length of 512
hostThe address of the server.
portThe port of the service.
java.io.IOExceptionIf an error occurs while sending the datagram.
java.io.IOExceptionIf an error occurs while receiving the datagram.