diff options
author | Michael Koch <konqueror@gmx.de> | 2002-12-19 14:39:58 +0000 |
---|---|---|
committer | Michael Koch <konqueror@gmx.de> | 2002-12-19 14:39:58 +0000 |
commit | 19e8f7d227529adb38850289647b62ad52241a74 (patch) | |
tree | c5249f391b66271b15e53c761cdeeee63b3a7133 | |
parent | 79368310228f6f2cca401789dc2e9d399f30bedf (diff) | |
download | classpath-19e8f7d227529adb38850289647b62ad52241a74.tar.gz |
2002-12-19 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java
(remoteAddress): Renamed from remote_addr.
(remotePort): Renamed from remote_port.
(getSoTimeout): Throw exception
if not initialized socket successfully.
(getSendBufferSize): Throw exception
if not initialized socket successfully.
(getReceiveBufferSize): Throw exception
if not initialized socket successfully.
(receive): Added SecurityManager check.
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | java/net/DatagramSocket.java | 37 |
2 files changed, 37 insertions, 13 deletions
@@ -1,6 +1,19 @@ 2002-12-19 Michael Koch <konqueror@gmx.de> * java/net/DatagramSocket.java + (remoteAddress): Renamed from remote_addr. + (remotePort): Renamed from remote_port. + (getSoTimeout): Throw exception + if not initialized socket successfully. + (getSendBufferSize): Throw exception + if not initialized socket successfully. + (getReceiveBufferSize): Throw exception + if not initialized socket successfully. + (receive): Added SecurityManager check. + +2002-12-19 Michael Koch <konqueror@gmx.de> + + * java/net/DatagramSocket.java (factory): New member to store default DatagramSocketFactory object. (bind): New method. (getChannel): New method. diff --git a/java/net/DatagramSocket.java b/java/net/DatagramSocket.java index a2d8ea9d2..6419c0eeb 100644 --- a/java/net/DatagramSocket.java +++ b/java/net/DatagramSocket.java @@ -86,20 +86,18 @@ public class DatagramSocket /** * This is the address we are "connected" to */ - private InetAddress remote_addr; + private InetAddress remoteAddress; /** * This is the port we are "connected" to */ - private int remote_port = -1; + private int remotePort = -1; /** * Is this a "connected" datagram socket? */ private boolean connected = false; - // Constructors - /** * Initializes a new instance of <code>DatagramSocket</code> that binds to * a random port and every address on the local machine. @@ -195,7 +193,7 @@ public class DatagramSocket */ public InetAddress getInetAddress() { - return remote_addr; + return remoteAddress; } /** @@ -209,7 +207,7 @@ public class DatagramSocket */ public int getPort() { - return remote_port; + return remotePort; } /** @@ -220,7 +218,7 @@ public class DatagramSocket public InetAddress getLocalAddress() { if (impl == null) - return(null); + return null; // FIXME: According to libgcj, checkConnect() is supposed to be called // before performing this operation. Problems: 1) We don't have the @@ -256,6 +254,9 @@ public class DatagramSocket */ public synchronized int getSoTimeout() throws SocketException { + if (impl == null) + throw new SocketException ("Cannot initialize Socket implementation"); + Object timeout = impl.getOption(SocketOptions.SO_TIMEOUT); if (timeout instanceof Integer) @@ -296,6 +297,9 @@ public class DatagramSocket */ public int getSendBufferSize() throws SocketException { + if (impl == null) + throw new SocketException ("Cannot initialize Socket implementation"); + Object obj = impl.getOption(SocketOptions.SO_SNDBUF); if (obj instanceof Integer) @@ -337,6 +341,9 @@ public class DatagramSocket */ public int getReceiveBufferSize() throws SocketException { + if (impl == null) + throw new SocketException ("Cannot initialize Socket implementation"); + Object obj = impl.getOption(SocketOptions.SO_RCVBUF); if (obj instanceof Integer) @@ -393,8 +400,8 @@ public class DatagramSocket if (sm != null) sm.checkConnect(addr.getHostName(), port); - this.remote_addr = addr; - this.remote_port = port; + this.remoteAddress = addr; + this.remotePort = port; /* FIXME: Shit, we can't do this even though the OS supports it since this method isn't in DatagramSocketImpl. */ @@ -413,8 +420,8 @@ public class DatagramSocket public void disconnect() { // FIXME: See my comments on connect() - this.remote_addr = null; - this.remote_port = -1; + this.remoteAddress = null; + this.remotePort = -1; connected = false; } @@ -435,6 +442,10 @@ public class DatagramSocket s.checkAccept(p.getAddress().getHostAddress(), p.getPort()); impl.receive(p); + + SecurityManager s = System.getSecurityManager(); + if (s != null && isConnected ()) + s.checkAccept (p.getAddress().getHostName (), p.getPort ()); } /** @@ -554,7 +565,7 @@ public class DatagramSocket */ public boolean isConnected() { - return remote_addr != null; + return remoteAddress != null; } /** @@ -568,7 +579,7 @@ public class DatagramSocket if (!isConnected ()) return null; - return new InetSocketAddress (remote_addr, remote_port); + return new InetSocketAddress (remoteAddress, remotePort); } /** |