This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
DatagramSocket Java2 interfaces
- From: Tony Kimball <alk at pobox dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Wed, 3 Jul 2002 23:35:31 -0500
- Subject: DatagramSocket Java2 interfaces
- Reply-to: alk at pobox dot com
cvs -z3 diff DatagramSocket.java
Index: DatagramSocket.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.10
diff -r1.10 DatagramSocket.java
27a28,29
> InetAddress remoteAddr = null;
> int remotePort = -1;
131,134c133,140
< SecurityManager s = System.getSecurityManager();
< if (s != null)
< s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
<
---
> if (p == null) {
> SecurityManager s = System.getSecurityManager();
> if (s != null)
> s.checkAccept(p.getAddress().getHostAddress(), p.getPort());
> } else if ((p.getPort() != remotePort || !p.getAddress().equals(remoteAddr))) {
> throw new IllegalArgumentException("Inconsistent packet address for connection to "
> +remoteAddr+" port "+remotePort);
> }
141,142c147,149
< SecurityManager s = System.getSecurityManager();
< if (s != null)
---
> if (p == null) {
> SecurityManager s = System.getSecurityManager();
> if (s != null)
148c155
< s.checkConnect(addr.getHostAddress(), p.getPort());
---
> s.checkConnect(addr.getHostAddress(), p.getPort());
150c157,160
<
---
> } else if ((p.getPort() != remotePort || !p.getAddress().equals(remoteAddr))) {
> throw new IllegalArgumentException("Inconsistent packet address for connection to "
> +remoteAddr+" port "+remotePort);
> }
163,191c173,219
< // JDK1.2
< // public void connect(InetAddress address, int port)
< // {
< // }
<
< // JDK1.2
< // public void disconnect()
< // {
< // }
<
< // JDK1.2
< // public InetAddress getInetAddress()
< // {
< // }
<
< // JDK1.2
< // public int getPort()
< // {
< // }
<
< /**
< * This method returns the value of the system level socket option
< * SO_RCVBUF, which is used by the operating system to tune buffer
< * sizes for data transfers.
< *
< * @return The receive buffer size.
< *
< * @exception SocketException If an error occurs.
< *
---
> public void connect(InetAddress address, int port) {
> synchronized (this) {
> SecurityManager s = System.getSecurityManager();
> if (s != null)
> {
> if (address.isMulticastAddress())
> s.checkMulticast(address);
> else
> s.checkConnect(address.getHostAddress(), port);
>
> remoteAddr = address;
> remotePort = port;
> if (remotePort < -1 || remotePort > 65535) {
> throw new IllegalArgumentException("bad remote parameters for local port "+
> impl.localPort);
> }
> }
> }
> }
>
> public void disconnect()
> {
> synchronized (this) {
> remotePort = -1;
> remoteAddr = null;
> }
> }
>
> public InetAddress getInetAddress()
> {
> return remoteAddr;
> }
>
> public int getPort()
> {
> return remotePort;
> }
>
> /**
> * This method returns the value of the system level socket option
> SO_RCVBUF, which is used by the operating system to tune buffer
> * sizes for data transfers.
> *
> @return The receive buffer size.
> *
> * @exception SocketException If an error occurs.
> *