aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/MulticastSocket.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-11-25 10:09:48 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-11-25 10:09:48 +0000
commit66e5d61fba14cd936e0183ba014703c196269590 (patch)
tree5913f733c032c45af5ae571b8e9319e4d4101b1c /libjava/java/net/MulticastSocket.java
parentdcb5fe8b43cd9eaddbfe4bfae93653e817867420 (diff)
downloadgcc-66e5d61fba14cd936e0183ba014703c196269590.zip
gcc-66e5d61fba14cd936e0183ba014703c196269590.tar.gz
gcc-66e5d61fba14cd936e0183ba014703c196269590.tar.bz2
2003-11-25 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java (factory): Made private. (closed): Removed. (DatagramSocket): Check impl argument, use constructor with SocketAddress argument. (close): Set impl to null, use isClosed(). (isClosed): Check for impl == null. (getLocalAddress): Use isClosed(). (getLocalPort): Check if socket is closed. (getSoTimeout): Likewise. (setSoTimeout): Likewise. (getSendBufferSize): Likewise. (setSendBufferSize): Likewise. (getReceiveBufferSize): Likewise. (setReceiveBufferSize): Likewise. (receive): Likewise. (send): Likewise. (bind): Likewise. (connect): Likewise. (setReuseAddress): Likewise. (getReuseAddress): Likewise. (setBroadcast): Likewise. (getBroadcast): Likewise. (setTrafficClass): Likewise. (getTrafficClass): Likewise. * java/net/MulticastSocket.java (getInterface): Check if socket is closed. (getTTL): Likewise. (getTimeToLive): Likewise. (setInterface): Likewise. (setNetworkInterface): Likewise. (getNetworkInterface): Likewise. (setLoopbackMode): Likewise. (setTTL): Likewise. (setTimeToLive): Likewise. (joinGroup): Likewise. (leaveGroup): Likewise. (send): Likewise. * java/net/ServerSocket.java (closed): Removed. (close): Check if socket is closed, set impl to null. (isClosed): Check impl == null; (ServerSocket): Check impl argument. (getInetAddress): Check if socket is bound. (getLocalPort): Likewise. (getLocalSocketAddress): Likewise. (bind): Check if socket is closed. (implAccept): Likewise. (setSoTimeout): Likewise. (getSoTimeout): Likewise. (setReuseAddress): Likewise. (getReuseAddress): Likewise. (setReceiveBufferSize): Likewise. (getReceiveBufferSize): Likewise. (toString): Make output compliant to JDK 1.4.2. * java/net/Socket.java (closed): Removed. (Socket): Fixed documentation. (connect): Check if socket is closed, changed exception text, fixed documentation. (getInputStream): Check of socket is closed and connected. (getOutputStream): Likewise. (bind): Check if socket is closed. (setTcpNoDelay): Likewise. (getTcpNoDelay): Likewise. (setSoLinger): Likewise. (getSoLinger): Likewise. (sendUrgentData): Likewise. (setOOBInline): Likewise. (getOOBInline): Likewise. (setSoTimeout): Likewise. (getSoTimeout): Likewise. (setSendBufferSize): Likewise. (getSendBufferSize): Likewise. (setReceiveBufferSize): Likewise. (getReceiveBufferSize): Likewise. (setKeepAlive): Likewise. (getKeepAlive): Likewise. (close): Likewise. (shutdownInput): Likewise. (shutdownOutput): Likewise. (getReuseAddress): Likewise. (getTrafficClass): Likewise. (setTrafficClass): Likewise. (isClosed): Check impl == null. (toString): Added missing ']'. From-SVN: r73918
Diffstat (limited to 'libjava/java/net/MulticastSocket.java')
-rw-r--r--libjava/java/net/MulticastSocket.java51
1 files changed, 42 insertions, 9 deletions
diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java
index 097d52e..9c4d3e2 100644
--- a/libjava/java/net/MulticastSocket.java
+++ b/libjava/java/net/MulticastSocket.java
@@ -125,6 +125,9 @@ public class MulticastSocket extends DatagramSocket
*/
public InetAddress getInterface() throws SocketException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
}
@@ -143,6 +146,9 @@ public class MulticastSocket extends DatagramSocket
*/
public byte getTTL() throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
// Use getTTL here rather than getTimeToLive in case we're using an impl
// other than the default PlainDatagramSocketImpl and it doesn't have
// getTimeToLive yet.
@@ -161,6 +167,9 @@ public class MulticastSocket extends DatagramSocket
*/
public int getTimeToLive() throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
return impl.getTimeToLive();
}
@@ -175,6 +184,9 @@ public class MulticastSocket extends DatagramSocket
*/
public void setInterface(InetAddress addr) throws SocketException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
}
@@ -192,9 +204,8 @@ public class MulticastSocket extends DatagramSocket
public void setNetworkInterface(NetworkInterface netIf)
throws SocketException
{
- if (impl == null)
- throw new SocketException (
- "MulticastSocket: Cant access socket implementation");
+ if (isClosed())
+ throw new SocketException("socket is closed");
Enumeration e = netIf.getInetAddresses ();
@@ -219,9 +230,8 @@ public class MulticastSocket extends DatagramSocket
public NetworkInterface getNetworkInterface()
throws SocketException
{
- if (impl == null)
- throw new SocketException (
- "MulticastSocket: Cant access socket implementation");
+ if (isClosed())
+ throw new SocketException("socket is closed");
InetAddress address =
(InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF);
@@ -246,9 +256,8 @@ public class MulticastSocket extends DatagramSocket
*/
public void setLoopbackMode(boolean disable) throws SocketException
{
- if (impl == null)
- throw new SocketException (
- "MulticastSocket: Cant access socket implementation");
+ if (isClosed())
+ throw new SocketException("socket is closed");
impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
}
@@ -262,6 +271,9 @@ public class MulticastSocket extends DatagramSocket
*/
public boolean getLoopbackMode() throws SocketException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
Object obj = impl.getOption (SocketOptions.IP_MULTICAST_LOOP);
if (obj instanceof Boolean)
@@ -284,6 +296,9 @@ public class MulticastSocket extends DatagramSocket
*/
public void setTTL(byte ttl) throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
// Use setTTL here rather than setTimeToLive in case we're using an impl
// other than the default PlainDatagramSocketImpl and it doesn't have
// setTimeToLive yet.
@@ -302,6 +317,9 @@ public class MulticastSocket extends DatagramSocket
*/
public void setTimeToLive(int ttl) throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
if (ttl <= 0 || ttl > 255)
throw new IllegalArgumentException("Invalid ttl: " + ttl);
@@ -319,6 +337,9 @@ public class MulticastSocket extends DatagramSocket
*/
public void joinGroup(InetAddress mcastaddr) throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
if (! mcastaddr.isMulticastAddress())
throw new IOException("Not a Multicast address");
@@ -340,6 +361,9 @@ public class MulticastSocket extends DatagramSocket
*/
public void leaveGroup(InetAddress mcastaddr) throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
if (! mcastaddr.isMulticastAddress())
throw new IOException("Not a Multicast address");
@@ -371,6 +395,9 @@ public class MulticastSocket extends DatagramSocket
public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf)
throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
if (! (mcastaddr instanceof InetSocketAddress))
throw new IllegalArgumentException ("SocketAddress type not supported");
@@ -406,6 +433,9 @@ public class MulticastSocket extends DatagramSocket
public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf)
throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
InetSocketAddress tmp = (InetSocketAddress) mcastaddr;
if (! tmp.getAddress ().isMulticastAddress ())
@@ -434,6 +464,9 @@ public class MulticastSocket extends DatagramSocket
*/
public synchronized void send(DatagramPacket p, byte ttl) throws IOException
{
+ if (isClosed())
+ throw new SocketException("socket is closed");
+
SecurityManager s = System.getSecurityManager();
if (s != null)
{