This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java.net.DatagramPacket: update to JDK 1.4 API (with attachment)


Hello list,


Another diff from me. Please review and comment. The intendation is different 
from the one used in other parts of the original file. I will re-indent the 
original file when this diff is commited. Can I silently commit the 
re-indented file afterwards (I mean without sending a diff here first) ?


Michael

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.1419
diff -u -b -r1.1419 ChangeLog
--- ChangeLog	28 Aug 2002 20:05:33 -0000	1.1419
+++ ChangeLog	29 Aug 2002 06:04:46 -0000
@@ -1,3 +1,7 @@
+2002-08-29  Michael Koch  <konqueror@gmx.de>
+
+	* java/net/DatagramPacket.java: updated to JDK 1.4 API
+
 2002-08-28  Tom Tromey  <tromey@redhat.com>
 
 	* java/lang/Class.h: Include Package.h.
Index: java/net/DatagramPacket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramPacket.java,v
retrieving revision 1.7
diff -u -b -r1.7 DatagramPacket.java
--- java/net/DatagramPacket.java	27 Aug 2002 17:47:26 -0000	1.7
+++ java/net/DatagramPacket.java	29 Aug 2002 06:04:46 -0000
@@ -186,6 +186,45 @@
     this(buf, 0, length, address, port);
   }
 
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param offset The offset into the buffer to start writing from.
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The socket address to send to
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public DatagramPacket(byte[] buf, int offset, int length, SocketAddress address)
+     throws SocketException
+  {
+    this(buf, offset, length, ((InetSocketAddress)address).getAddress(),
+         ((InetSocketAddress)address).getPort());
+  }
+
+  /**
+   * Initializes a new instance of <code>DatagramPacket</code> for
+   * transmitting packets across the network.
+   *
+   * @param buf A buffer containing the data to send
+   * @param length The length of the buffer (must be <= buf.length)
+   * @param address The socket address to send to
+   *
+   * @exception SocketException If an error occurs
+   *
+   * @since 1.4
+   */
+  public DatagramPacket(byte[] buf, int length, SocketAddress address)
+    throws SocketException
+  {
+    this(buf, 0, length, ((InetSocketAddress)address).getAddress(),
+         ((InetSocketAddress)address).getPort());
+  }
+
 /**
   * Returns the address that this packet is being sent to or, if it was used
   * to receive a packet, the address that is was received from.  If the
@@ -275,6 +314,38 @@
       throw new IllegalArgumentException("Invalid port: " + iport);
 
     port = iport;
+  }
+
+  /**
+   * Sets the address of the remote host this package will be sent
+   *
+   * @param address The socket address of the remove host
+   *
+   * @exception IllegalArgumentException If an error occurs
+   *
+   * @since 1.4
+   */
+  public void setSocketAddress(SocketAddress address)
+    throws IllegalArgumentException
+  {
+    if (address == null) throw new IllegalArgumentException();
+
+    InetSocketAddress tmp = (InetSocketAddress)address;
+    this.address = tmp.getAddress();
+    this.port = tmp.getPort();
+  }
+
+  /**
+   * Gets the socket address of the host this packet
+   * will be sent to/is coming from
+   *
+   * @return The socket address of the remote host
+   * 
+   * @since 1.4
+   */
+  public SocketAddress getSocketAddress()
+  {
+    return new InetSocketAddress (address, port);
   }
 
 /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]