2362N/A * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This class represents a datagram packet. 0N/A * Datagram packets are used to implement a connectionless packet 0N/A * delivery service. Each message is routed from one machine to 0N/A * another based solely on information contained within that packet. 0N/A * Multiple packets sent from one machine to another might be routed 0N/A * differently, and might arrive in any order. Packet delivery is 0N/A * @author Pavani Diwanji 0N/A * @author Benjamin Renaud 0N/A * Perform class initialization 0N/A * The fields of this class are package-private since DatagramSocketImpl 0N/A * classes needs to access them. 0N/A * Constructs a <code>DatagramPacket</code> for receiving packets of 0N/A * length <code>length</code>, specifying an offset into the buffer. 0N/A * The <code>length</code> argument must be less than or equal to 0N/A * <code>buf.length</code>. 0N/A * @param buf buffer for holding the incoming datagram. 0N/A * @param offset the offset for the buffer 0N/A * @param length the number of bytes to read. 0N/A * Constructs a <code>DatagramPacket</code> for receiving packets of 0N/A * length <code>length</code>. 0N/A * The <code>length</code> argument must be less than or equal to 0N/A * <code>buf.length</code>. 0N/A * @param buf buffer for holding the incoming datagram. 0N/A * @param length the number of bytes to read. 0N/A * Constructs a datagram packet for sending packets of length 0N/A * <code>length</code> with offset <code>ioffset</code>to the 0N/A * specified port number on the specified host. The 0N/A * <code>length</code> argument must be less than or equal to 0N/A * <code>buf.length</code>. 0N/A * @param buf the packet data. 0N/A * @param offset the packet data offset. 0N/A * @param length the packet data length. 0N/A * @param address the destination address. 0N/A * @param port the destination port number. 0N/A * @see java.net.InetAddress 0N/A * Constructs a datagram packet for sending packets of length 0N/A * <code>length</code> with offset <code>ioffset</code>to the 0N/A * specified port number on the specified host. The 0N/A * <code>length</code> argument must be less than or equal to 0N/A * <code>buf.length</code>. 0N/A * @param buf the packet data. 0N/A * @param offset the packet data offset. 0N/A * @param length the packet data length. 0N/A * @param address the destination socket address. 0N/A * @throws IllegalArgumentException if address type is not supported 0N/A * @see java.net.InetAddress 0N/A * Constructs a datagram packet for sending packets of length 0N/A * <code>length</code> to the specified port number on the specified 0N/A * host. The <code>length</code> argument must be less than or equal 0N/A * to <code>buf.length</code>. 0N/A * @param buf the packet data. 0N/A * @param length the packet length. 0N/A * @param address the destination address. 0N/A * @param port the destination port number. 0N/A * @see java.net.InetAddress 0N/A * Constructs a datagram packet for sending packets of length 0N/A * <code>length</code> to the specified port number on the specified 0N/A * host. The <code>length</code> argument must be less than or equal 0N/A * to <code>buf.length</code>. 0N/A * @param buf the packet data. 0N/A * @param length the packet length. 0N/A * @param address the destination address. 0N/A * @throws IllegalArgumentException if address type is not supported 0N/A * @see java.net.InetAddress 0N/A * Returns the IP address of the machine to which this datagram is being 0N/A * sent or from which the datagram was received. 0N/A * @return the IP address of the machine to which this datagram is being 0N/A * sent or from which the datagram was received. 0N/A * @see java.net.InetAddress 0N/A * @see #setAddress(java.net.InetAddress) 0N/A * Returns the port number on the remote host to which this datagram is 0N/A * being sent or from which the datagram was received. 0N/A * @return the port number on the remote host to which this datagram is 0N/A * being sent or from which the datagram was received. 0N/A * @see #setPort(int) 0N/A * Returns the data buffer. The data received or the data to be sent 0N/A * starts from the <code>offset</code> in the buffer, 0N/A * and runs for <code>length</code> long. 0N/A * @return the buffer used to receive or send data 0N/A * @see #setData(byte[], int, int) 0N/A * Returns the offset of the data to be sent or the offset of the 0N/A * @return the offset of the data to be sent or the offset of the 0N/A * Returns the length of the data to be sent or the length of the 0N/A * @return the length of the data to be sent or the length of the 0N/A * @see #setLength(int) 0N/A * Set the data buffer for this packet. This sets the 0N/A * data, length and offset of the packet. 0N/A * @param buf the buffer to set for this packet 0N/A * @param offset the offset into the data 0N/A * @param length the length of the data 0N/A * and/or the length of the buffer used to receive data 0N/A * @exception NullPointerException if the argument is null 0N/A /* this will check to see if buf is null */ 0N/A * Sets the IP address of the machine to which this datagram 0N/A * @param iaddr the <code>InetAddress</code> 0N/A * @see #getAddress() 0N/A * Sets the port number on the remote host to which this datagram 0N/A * @param iport the port number 0N/A * Sets the SocketAddress (usually IP address + port number) of the remote 0N/A * host to which this datagram is being sent. 0N/A * @param address the <code>SocketAddress</code> 0N/A * @throws IllegalArgumentException if address is null or is a 0N/A * SocketAddress subclass not supported by this socket 0N/A * @see #getSocketAddress 0N/A * Gets the SocketAddress (usually IP address + port number) of the remote 0N/A * host that this packet is being sent to or is coming from. 0N/A * @return the <code>SocketAddress</code> 0N/A * @see #setSocketAddress 0N/A * Set the data buffer for this packet. With the offset of 0N/A * this DatagramPacket set to 0, and the length set to 0N/A * the length of <code>buf</code>. 0N/A * @param buf the buffer to set for this packet. 0N/A * @exception NullPointerException if the argument is null. 0N/A * Set the length for this packet. The length of the packet is 0N/A * the number of bytes from the packet's data buffer that will be 0N/A * sent, or the number of bytes of the packet's data buffer that 0N/A * will be used for receiving data. The length must be lesser or 0N/A * equal to the offset plus the length of the packet's buffer. 0N/A * @param length the length to set for this packet. 0N/A * @exception IllegalArgumentException if the length is negative 0N/A * of if the length is greater than the packet's data buffer 0N/A * Perform class load-time initializations.