From 7393decb70ea1bd5f69faab0648dd64ae94b2082 Mon Sep 17 00:00:00 2001 From: Michael Koch Date: Thu, 10 Oct 2002 05:19:22 +0000 Subject: 2002-10-08 Michael Koch * java/net/HttpURLConnection.java (getPermission): New method. (getErrorStream): New stub method. (getHeaderFieldDate): New stub method. * java/net/Inet4Address.java: (isLinkLocalAddress): Typo fixed. * java/net/InetAddress.java: (readResolve): New stubbed method (for serialization). (isAnyLocalAddress): New stubbed method. (isLoopbackAddress): New stubbed method. (isLinkLocalAddress): New stubbed method. (isSiteLocalAddress): New stubbed method. (isMCGlobal): New stubbed method. (isMCNodeGlobal): New stubbed method. (isMCLinkLocal): New stubbed method. (isMCSiteLocal): New stubbed method. (isMCOrgLocal): New stubbed method. (getCanonicalHostName): New stubbed method. (getByAddress): Create instances of Inet4Address/Inet6Address, instead of InetAddress, documentation added. * java/net/MulticastSocket.java (getInterface): Removed FIXME. (getNetworkInterface): New method. (setNetworkInterface): New method. * java/net/NetworkInterface.java: (toString): Use property "line.separator" instead of "\n". * java/net/URLConnection.java (getContent): New stubbed method. * java/net/URLStreamHandler.java: (equals): New stubbed method. (hostsEqual): New stubbed method. (hashCode): New stubbed method. * java/net/natNetworkInterface.cc: (getRealNetworkInterfaces): Create Inet4Address object instead of InetAddress. From-SVN: r58002 --- libjava/java/net/MulticastSocket.java | 58 ++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'libjava/java/net/MulticastSocket.java') diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java index 04d07351ab6..2700ebee511 100644 --- a/libjava/java/net/MulticastSocket.java +++ b/libjava/java/net/MulticastSocket.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.net; import java.io.IOException; +import java.util.Enumeration; /** * Written using on-line Java Platform 1.2 API Specification, as well @@ -120,7 +121,6 @@ public class MulticastSocket extends DatagramSocket */ public InetAddress getInterface() throws SocketException { - // FIXME: Is it possible that an InetAddress wasn't returned from getOption? return (InetAddress) impl.getOption(SocketOptions.IP_MULTICAST_IF); } @@ -172,6 +172,58 @@ public class MulticastSocket extends DatagramSocket impl.setOption(SocketOptions.IP_MULTICAST_IF, inf); } + /** + * Sets the local network interface used to send multicast messages + * + * @param netIF The local network interface used to send multicast messages + * + * @exception SocketException If an error occurs + * + * @see MulticastSocket:getNetworkInterface + * + * @since 1.4 + */ + public void setNetworkInterface(NetworkInterface netIf) + throws SocketException + { + if (impl == null) + throw new SocketException ( + "MulticastSocket: Cant access socket implementation"); + + Enumeration e = netIf.getInetAddresses (); + + if (!e.hasMoreElements ()) + throw new SocketException ("MulticastSocket: Error"); + + InetAddress address = (InetAddress) e.nextElement (); + impl.setOption (SocketOptions.IP_MULTICAST_IF, address); + } + + /** + * Gets the local network interface which is used to send multicast messages + * + * @return The local network interface to send multicast messages + * + * @exception SocketException If an error occurs + * + * @see MulticastSocket:setNetworkInterface + * + * @since 1.4 + */ + public NetworkInterface getNetworkInterface() + throws SocketException + { + if (impl == null) + throw new SocketException ( + "MulticastSocket: Cant access socket implementation"); + + InetAddress address = + (InetAddress) impl.getOption (SocketOptions.IP_MULTICAST_IF); + NetworkInterface netIf = NetworkInterface.getByInetAddress (address); + + return netIf; + } + /** * Disable/Enable local loopback of multicast packets. The option is used by * the platform's networking code as a hint for setting whether multicast @@ -188,6 +240,10 @@ public class MulticastSocket extends DatagramSocket */ public void setLoopbackMode(boolean disable) throws SocketException { + if (impl == null) + throw new SocketException ( + "MulticastSocket: Cant access socket implementation"); + impl.setOption (SocketOptions.IP_MULTICAST_LOOP, new Boolean (disable)); } -- cgit v1.2.3