1 16 package org.apache.commons.net; 17 18 import java.io.IOException ; 19 import java.net.DatagramPacket ; 20 import java.net.InetAddress ; 21 22 36 37 public class DiscardUDPClient extends DatagramSocketClient 38 { 39 40 public static final int DEFAULT_PORT = 9; 41 42 DatagramPacket _sendPacket; 43 44 public DiscardUDPClient() 45 { 46 _sendPacket = new DatagramPacket (new byte[0], 0); 47 } 48 49 50 61 public void send(byte[] data, int length, InetAddress host, int port) 62 throws IOException 63 { 64 _sendPacket.setData(data); 65 _sendPacket.setLength(length); 66 _sendPacket.setAddress(host); 67 _sendPacket.setPort(port); 68 _socket_.send(_sendPacket); 69 } 70 71 72 76 public void send(byte[] data, int length, InetAddress host) 77 throws IOException 78 { 79 send(data, length, host, DEFAULT_PORT); 80 } 81 82 83 87 public void send(byte[] data, InetAddress host) throws IOException 88 { 89 send(data, data.length, host, DEFAULT_PORT); 90 } 91 92 } 93 94 | Popular Tags |