aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/net/MulticastSocket.java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2002-10-10 05:19:22 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2002-10-10 05:19:22 +0000
commit7393decb70ea1bd5f69faab0648dd64ae94b2082 (patch)
treef965712000cf470fbf9fff4d979f57fb6d1f2b12 /libjava/java/net/MulticastSocket.java
parent402a402cabeb85a223952f822eb14af6c3094a4c (diff)
downloadgcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.zip
gcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.tar.gz
gcc-7393decb70ea1bd5f69faab0648dd64ae94b2082.tar.bz2
2002-10-08 Michael Koch <konqueror@gmx.de>
* 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
Diffstat (limited to 'libjava/java/net/MulticastSocket.java')
-rw-r--r--libjava/java/net/MulticastSocket.java58
1 files changed, 57 insertions, 1 deletions
diff --git a/libjava/java/net/MulticastSocket.java b/libjava/java/net/MulticastSocket.java
index 04d0735..2700ebe 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);
}
@@ -173,6 +173,58 @@ public class MulticastSocket extends DatagramSocket
}
/**
+ * 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
* data will be looped back to the local socket.
@@ -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));
}