aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/MulticastSocket.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-11-26 14:33:41 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-11-26 14:33:41 +0000
commit4aa74bd346b862ac34704642f0483a057cfe73a3 (patch)
tree6357f88efab2b52d021092786f834f66d4006f2f /libjava/java/net/MulticastSocket.java
parent88096b2a59c659f94df962aca5f49d58602bbc8a (diff)
downloadgcc-4aa74bd346b862ac34704642f0483a057cfe73a3.zip
gcc-4aa74bd346b862ac34704642f0483a057cfe73a3.tar.gz
gcc-4aa74bd346b862ac34704642f0483a057cfe73a3.tar.bz2
2003-11-26 Michael Koch <konqueror@gmx.de>
* java/net/DatagramSocket.java (impl): Made private. (bound): New private member variable. (DatagramSocket): Fixed documentation, use getImpl(). (getImpl): New package-private method. (isClosed): Use getImpl(). (getLocalAddress): Completed documentation, use getImpl(). (getLocalPort): Use getImpl(). (getSoTimeout): Likewise. (setSoTimeout): Likewise. (getSendBufferSize): Likewise. (setSendBufferSize): Likewise. (getReceiveBufferSize): Likewise. (setReceiveBufferSize): Likewise. (connect): Likewise. (disconnect): Likewise. (receive): Likewise. (send): Likewise. (setReuseAddress): Likewise. (setTrafficClass): Likewise. (bind): Added message to exception. (isClosed): Completed documentation. (getChannel): Likewise. (connect): Added missing exception, refined exception message. (isBound): Completed documentation, just return bound. (isConnected): Completed documentation. (getRemoteSocketAddress): Likewise. (getReuseAddress): Completed documentation, use getImpl(). (setSoBroadcast): Likewise. (getSoBroadcast): Likewise. (getTrafficClass): Likewise. (getLocalSocketAddress): Simplified. * java/net/MulticastSocket.java (MulticastSocket): Removed comment not applying anymore. (getInterface): Use getImpl(). (getTTL): Likewise. (getTimeToLive): Likewise. (setInterface): Likewise. (setNetworkInterface): Likewise. (getNetworkInterface): Likewise. (setLoopback): Likewise. (getLoopback): Likewise. (setTTL): Likewise. (setTimeToLive): Likewise. (joinGroup): Likewise. (leaveGroup): Likewise. (send): Likewise. From-SVN: r73951
Diffstat (limited to 'libjava/java/net/MulticastSocket.java')
-rw-r--r--libjava/java/net/MulticastSocket.java50
1 files changed, 23 insertions, 27 deletions
diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java
index 9c4d3e2..12afc2f 100644
--- a/libjava/java/net/MulticastSocket.java
+++ b/libjava/java/net/MulticastSocket.java
@@ -67,10 +67,6 @@ import java.util.Enumeration;
*/
public class MulticastSocket extends DatagramSocket
{
- // FIXME: the local addr bound to the multicast socket can be reused;
- // unlike unicast sockets. It binds to any available network interface.
- // See p.1159 JCL book.
-
/**
* Create a MulticastSocket that this not bound to any address
*
@@ -128,7 +124,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed())
throw new SocketException("socket is closed");
- return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF);
+ return (InetAddress) getImpl().getOption(SocketOptions.IP_MULTICAST_IF);
}
/**
@@ -152,7 +148,7 @@ public class MulticastSocket extends DatagramSocket
// 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.
- return impl.getTTL();
+ return getImpl().getTTL();
}
/**
@@ -170,7 +166,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed())
throw new SocketException("socket is closed");
- return impl.getTimeToLive();
+ return getImpl().getTimeToLive();
}
/**
@@ -187,7 +183,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed())
throw new SocketException("socket is closed");
- impl.setOption(SocketOptions.IP_MULTICAST_IF, addr);
+ getImpl().setOption(SocketOptions.IP_MULTICAST_IF, addr);
}
/**
@@ -210,10 +206,10 @@ public class MulticastSocket extends DatagramSocket
Enumeration e = netIf.getInetAddresses ();
if (!e.hasMoreElements ())
- throw new SocketException ("MulticastSocket: Error");
+ throw new SocketException("no network devices found");
InetAddress address = (InetAddress) e.nextElement ();
- impl.setOption (SocketOptions.IP_MULTICAST_IF, address);
+ getImpl().setOption (SocketOptions.IP_MULTICAST_IF, address);
}
/**
@@ -234,7 +230,7 @@ public class MulticastSocket extends DatagramSocket
throw new SocketException("socket is closed");
InetAddress address =
- (InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF);
+ (InetAddress) getImpl().getOption (SocketOptions.IP_MULTICAST_IF);
NetworkInterface netIf = NetworkInterface.getByInetAddress (address);
return netIf;
@@ -259,7 +255,7 @@ public class MulticastSocket extends DatagramSocket
if (isClosed())
throw new SocketException("socket is closed");
- impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
+ getImpl().setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable));
}
/**
@@ -274,12 +270,12 @@ public class MulticastSocket extends DatagramSocket
if (isClosed())
throw new SocketException("socket is closed");
- Object obj = impl.getOption (SocketOptions.IP_MULTICAST_LOOP);
+ Object buf = getImpl().getOption (SocketOptions.IP_MULTICAST_LOOP);
- if (obj instanceof Boolean)
- return ((Boolean) obj).booleanValue ();
- else
- throw new SocketException ("Unexpected type");
+ if (buf instanceof Boolean)
+ return ((Boolean) buf).booleanValue();
+
+ throw new SocketException("unexpected type");
}
/**
@@ -302,7 +298,7 @@ public class MulticastSocket extends DatagramSocket
// 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.
- impl.setTTL(ttl);
+ getImpl().setTTL(ttl);
}
/**
@@ -323,7 +319,7 @@ public class MulticastSocket extends DatagramSocket
if (ttl <= 0 || ttl > 255)
throw new IllegalArgumentException("Invalid ttl: " + ttl);
- impl.setTimeToLive(ttl);
+ getImpl().setTimeToLive(ttl);
}
/**
@@ -347,7 +343,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null)
s.checkMulticast(mcastaddr);
- impl.join(mcastaddr);
+ getImpl().join(mcastaddr);
}
/**
@@ -371,7 +367,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null)
s.checkMulticast(mcastaddr);
- impl.leave(mcastaddr);
+ getImpl().leave(mcastaddr);
}
/**
@@ -410,7 +406,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null)
s.checkMulticast (tmp.getAddress ());
- impl.joinGroup (mcastaddr, netIf);
+ getImpl().joinGroup (mcastaddr, netIf);
}
/**
@@ -445,7 +441,7 @@ public class MulticastSocket extends DatagramSocket
if (s != null)
s.checkMulticast (tmp.getAddress ());
- impl.leaveGroup (mcastaddr, netIf);
+ getImpl().leaveGroup (mcastaddr, netIf);
}
/**
@@ -479,9 +475,9 @@ public class MulticastSocket extends DatagramSocket
s.checkConnect(addr.getHostAddress(), p.getPort());
}
- int oldttl = impl.getTimeToLive();
- impl.setTimeToLive(((int) ttl) & 0xFF);
- impl.send(p);
- impl.setTimeToLive(oldttl);
+ int oldttl = getImpl().getTimeToLive();
+ getImpl().setTimeToLive(((int) ttl) & 0xFF);
+ getImpl().send(p);
+ getImpl().setTimeToLive(oldttl);
}
} // class MulticastSocket