From ed08cfe4cd05b81e9dbdf33866c8e292a424fb67 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Wed, 25 Sep 2002 05:05:07 +0000 Subject: 2002-09-25 Michael Koch * java/net/DatagramPacket (DatagramPacket): Exception documentation added. (setData): Likewise. (setSocketAddress): Likewise. * java/net/DatagramSocketImpl.java (peek): Documentation addded. (peekData): Documentation addded. (send): Documentation addded. (receive): Documentation addded. (connect): New method. (disconnect): New method. (joinGroup): New abstract method. (leaveGroup): New abstract method. * java/net/InetSocketAddress.java (InetSocketAddress): Documentation added. (equals): final keyword added. (getAddress): final keyword added. (getHostName): final keyword added. (getPort): final keyword added. (hashCode): final keyword added. (isUnresolved): final keyword added. * java/net/MulticastSocket.java (MulticastSocket): Documentation added. (MulticastSocket): New method. (joinGroup): Documentation added. (joinGroup): New method. (leaveGroup): Documentation added. (leaveGroup): New method. (send): Documentation added. * java/net/NetworkInterface.java (getByName): Documentation added. (getByInetAddress): Documentation added. (getNetworkInterfaces): Documentation added. * java/net/PlainDatagramSocketImpl.java (connect): New method. (disconnect): New method. * java/net/SocketImpl.java (create): Documentation added. (shutdownInput): Convert public to protected, as it always was. (shutdownOutput): Convert public to protected, as it always was. * java/net/SocketOptions.java (whole file): Reintented. * java/net/URLClassLoader.java (URLClassLoader): SecurityManager check added, documentation added. (findResources): Documentation added. (findClass): Documentation added. (newInstance): More correct method arguments. * java/net/URLConnection.java (connect): Documentation added. (getContent): Documentation added. (getPermission): Documentation added. (getInputStream): Documentation added. (getOutputStream): Documentation added. (setDoInput): Throw correct exception, documentation added. (setDoOutput): Throw correct exception, documentation added. (setAllowUserInteraction): Throw correct exception, documentation added. (setUseCaches): Throw correct exception, documentation added. (setIfModifiedSince): Throw correct exception, documentation added. (setRequestProperty): Throw exception, documentation added. (addRequestProperty): Throw exception, documentation added. (getRequestProperty): Throw exception, documentation added. (getRequestProperties): Documentation added. (setContentHandlerFactory): Documentation added. (guessContentTypeFromName): protected to public. (setFileNameMap): Documentation added. * java/net/URLDecoder.java (URLDecoder): New method. (decode): Documentation added. (whole file): Reindented. * java/net/URLEncoder.java (encode): Documentation added. * java/net/natPlainDatagramSocketImpl.cc (connect): New method. (disconnect): New method. * javax/naming/RefAddr: (addrType): addrType was never final. (equals): Fix typo in method name. * javax/naming/BinaryRefAddr: (equals): Fix typo in method name. From-SVN: r57487 --- libjava/java/net/MulticastSocket.java | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) (limited to 'libjava/java/net/MulticastSocket.java') diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java index 88cb149633d..b3582605a57 100644 --- a/libjava/java/net/MulticastSocket.java +++ b/libjava/java/net/MulticastSocket.java @@ -73,6 +73,8 @@ public class MulticastSocket extends DatagramSocket * Create a MulticastSocket that this not bound to any address * * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation */ public MulticastSocket() throws IOException { @@ -85,12 +87,30 @@ public class MulticastSocket extends DatagramSocket * @param port The port to bind to * * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation */ public MulticastSocket(int port) throws IOException { super(port, null); } + /** + * Create a multicast socket bound to the specified SocketAddress. + * + * @param address The SocketAddress the multicast socket will be bound to + * + * @exception IOException If an error occurs + * @exception SecurityException If a security manager exists and its + * checkListen method doesn't allow the operation + * + * @since 1.4 + */ + public MulticastSocket(SocketAddress address) throws IOException + { + super(address); + } + /** * Returns the interface being used for multicast packets * @@ -232,6 +252,7 @@ public class MulticastSocket extends DatagramSocket * @param addr The address of the group to join * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public void joinGroup(InetAddress mcastaddr) throws IOException { @@ -251,6 +272,7 @@ public class MulticastSocket extends DatagramSocket * @param addr The address of the group to leave * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public void leaveGroup(InetAddress mcastaddr) throws IOException { @@ -264,6 +286,74 @@ public class MulticastSocket extends DatagramSocket impl.leave(mcastaddr); } + /** + * Joins the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to join + * @param netIf The local network interface to receive the multicast + * messages on or null to defer the interface set by #setInterface or + * #setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException FIXME + * + * @see MulticastSocket:setInterface + * @see MulticastSocket:setNetworkInterface + * + * @since 1.4 + */ + public void joinGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + if (! (mcastaddr instanceof InetSocketAddress)) + throw new IllegalArgumentException ("SocketAddress type not supported"); + + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress ().isMulticastAddress ()) + throw new IOException ("Not a Multicast address"); + + // FIXME: check if this check is sufficient. Do we need to check the port ? + SecurityManager s = System.getSecurityManager (); + if (s != null) + s.checkMulticast (tmp.getAddress ()); + + impl.joinGroup (mcastaddr, netIf); + } + + /** + * Leaves the specified mulitcast group on a specified interface. + * + * @param mcastaddr The multicast address to leave + * @param netIf The local networki interface or null to defer to the + * interface set by setInterface or setNetworkInterface + * + * @exception IOException If an error occurs + * @exception IllegalArgumentException If address type is not supported + * @exception SecurityException FIXME + * + * @see MulticastSocket:setInterface + * @see MulticastSocket:setNetworkInterface + * + * @since 1.4 + */ + public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) + throws IOException + { + InetSocketAddress tmp = (InetSocketAddress) mcastaddr; + + if (! tmp.getAddress ().isMulticastAddress ()) + throw new IOException ("Not a Multicast address"); + + // FIXME: do we need to check the port too, or is this sufficient ? + SecurityManager s = System.getSecurityManager (); + if (s != null) + s.checkMulticast (tmp.getAddress ()); + + impl.leaveGroup (mcastaddr, netIf); + } + /** * Sends a packet of data to a multicast address with a TTL that is * different from the default TTL on this socket. The default TTL for @@ -273,6 +363,7 @@ public class MulticastSocket extends DatagramSocket * @param ttl The TTL for this packet * * @exception IOException If an error occurs + * @exception SecurityException FIXME */ public synchronized void send(DatagramPacket p, byte ttl) throws IOException { -- cgit v1.2.3