Hi,
this is the patch which removes VMPlainDatagramSocketImpl.

However I tried getting the multicast stuff working. So far I succeeded for IP4
sockets. Running in Azureus I get a "Protocol not available" in the native part
of setMulticastInterface6.

Casey, can you help me with this stuff? I am feeling lost here :|

Here is the how the ChangeLog would look like:

2006-10-09  Robert Schuster  <[EMAIL PROTECTED]>

        * gnu/java/net/PlainDatagramSocketImpl.java:
        (connect): Use VMChannel instance for connect call.
        (getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
        (setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
        (setOption): Handle multicast options.
        (getOption): Handle multicast options.
        * gnu/java/net/PlainSocketImpl.java:
        (getTimeToLive): Call VMPlainSocketImpl.getTimeToLive.
        (setTimeToLive): Call VMPlainSocketImpl.setTimeToLive.
        (setOption): Handle multicast options.
        (getOption): Handle multicast options.
        * include/Makefile.am: Removed all occurences of
        gnu_java_net_VMPlainDatagramSocketImpl.h.
        * include/gnu_java_net_VMPlainDatagramSocketImpl.h: Removed.
        * native/jni/java-net/Makefile.am: Removed
        gnu_java_net_VMPlainDatagramSocketImpl.c from sources.
        * native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c:
        Removed.
        as SocketException, declare to throw SocketException.
        * native/jni/java-nio/gnu_java_nio_VMChannel.c: Added definitions
        for SocketException and ConnectException.
        (Java_gnu_java_nio_VMChannel_connect): Throw SocketException instead
        of IOException.
        (Java_gnu_java_nio_VMChannel_connect6): Throw SocketException instead
        of IOException.
        * native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c: Added
        CPNET_IP_TTL to java_sockopt enum.
        (Java_gnu_java_net_VMPlainSocketImpl_setOption): Handle CPNET_IP_TTL
        case.
        (Java_gnu_java_net_VMPlainSocketImpl_getOption): Handle CPNET_IP_TTL
        case.
        (Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface): New
        function.
        (Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface): New
        function.
        (Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6): New
        function.
        * vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java: Removed.
        * vm/reference/gnu/java/nio/VMChannel.java:
        (connect(int, byte[], int, int)): Declare to throw SocketException.
        (connect6): Declare to throw SocketException.
        (connect(InetSocketAddress, int)): Catch IOException and rethrow
        * vm/reference/gnu/java/net/VMPlainSocketImpl.java:
        (setTimeToLive): New method.
        (getTimeToLive): New method.
        (setMulticastInterface(int, InetAddress)): New method.
        (setMulticastInterface(int, int, Inet4Address): New method.
        (setMulticastInterface6(int, int, Inet6Address): New method.
        * NEWS: Documented VM interface changes.
Index: gnu/java/net/PlainSocketImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/PlainSocketImpl.java,v
retrieving revision 1.14
diff -u -r1.14 PlainSocketImpl.java
--- gnu/java/net/PlainSocketImpl.java	17 Sep 2006 07:31:41 -0000	1.14
+++ gnu/java/net/PlainSocketImpl.java	9 Oct 2006 23:58:11 -0000
@@ -150,7 +150,8 @@
       {
         case IP_MULTICAST_IF:
         case IP_MULTICAST_IF2:
-          throw new UnsupportedOperationException("FIXME");
+          impl.setMulticastInterface(optionId, (InetAddress) value);
+          break;
 
         case IP_MULTICAST_LOOP:
         case SO_BROADCAST:
@@ -198,8 +199,8 @@
           }
       }
     if (optionId == IP_MULTICAST_IF || optionId == IP_MULTICAST_IF2)
-      throw new UnsupportedOperationException ("can't get option " +
-                                               optionId + " yet");
+      return impl.getMulticastInterface(optionId);
+
     return impl.getOption(optionId);
   }
 
Index: gnu/java/net/PlainDatagramSocketImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/net/PlainDatagramSocketImpl.java,v
retrieving revision 1.13
diff -u -r1.13 PlainDatagramSocketImpl.java
--- gnu/java/net/PlainDatagramSocketImpl.java	22 Sep 2006 00:11:56 -0000	1.13
+++ gnu/java/net/PlainDatagramSocketImpl.java	9 Oct 2006 23:58:11 -0000
@@ -42,7 +42,6 @@
 
 import java.io.IOException;
 import java.io.InterruptedIOException;
-import java.lang.reflect.Field;
 import java.net.DatagramPacket;
 import java.net.DatagramSocketImpl;
 import java.net.InetAddress;
@@ -69,7 +68,6 @@
  */
 public final class PlainDatagramSocketImpl extends DatagramSocketImpl
 {
-  
   private final VMChannel channel;
   
   /**
@@ -171,7 +169,7 @@
    */
   protected void connect(InetAddress addr, int port) throws SocketException
   {
-    VMPlainDatagramSocketImpl.connect(this, addr, port);
+    channel.connect(new InetSocketAddress(addr, port), 0);
   }
 
   /**
@@ -203,7 +201,7 @@
    */
   protected synchronized void setTimeToLive(int ttl) throws IOException
   {
-    setOption(VMPlainDatagramSocketImpl.IP_TTL, new Integer(ttl));
+    impl.setTimeToLive(ttl);
   }
 
   /**
@@ -215,12 +213,7 @@
    */
   protected synchronized int getTimeToLive() throws IOException
   {
-    Object obj = getOption(VMPlainDatagramSocketImpl.IP_TTL);
-
-    if (! (obj instanceof Integer))
-      throw new IOException("Internal Error");
-
-    return ((Integer) obj).intValue();
+    return impl.getTimeToLive();
   }
 
   protected int getLocalPort()
@@ -318,15 +311,38 @@
   /**
    * Sets the value of an option on the socket
    *
-   * @param option_id The identifier of the option to set
-   * @param val The value of the option to set
+   * @param optionId The identifier of the option to set
+   * @param value The value of the option to set
    *
    * @exception SocketException If an error occurs
    */
-  public synchronized void setOption(int option_id, Object val)
+  public synchronized void setOption(int optionId, Object value)
     throws SocketException
   {
-    impl.setOption(option_id, val);
+    switch (optionId)
+      {
+        case IP_MULTICAST_IF:
+        case IP_MULTICAST_IF2:
+          impl.setMulticastInterface(optionId, (InetAddress) value);
+          break;
+
+        case IP_MULTICAST_LOOP:
+        case SO_BROADCAST:
+        case SO_KEEPALIVE:
+        case SO_OOBINLINE:
+        case TCP_NODELAY:
+        case IP_TOS:
+        case SO_LINGER:
+        case SO_RCVBUF:
+        case SO_SNDBUF:
+        case SO_TIMEOUT:
+        case SO_REUSEADDR:
+          impl.setOption(optionId, value);
+          return;
+
+      default:
+        throw new SocketException("cannot set option " + optionId);
+      }
   }
 
   /**
Index: include/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/include/Makefile.am,v
retrieving revision 1.71
diff -u -r1.71 Makefile.am
--- include/Makefile.am	20 Sep 2006 21:39:41 -0000	1.71
+++ include/Makefile.am	9 Oct 2006 23:58:11 -0000
@@ -125,7 +125,6 @@
 $(GTKPEER_H_FILES) \
 $(QTPEER_H_FILES) \
 $(GCONF_PREFS_FILES) \
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h \
 $(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h \
 $(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h \
 $(top_srcdir)/include/gnu_java_nio_EpollSelectorImpl.h \
@@ -180,8 +179,6 @@
 $(top_srcdir)/include/gnu_java_util_prefs_gconf_%.h: $(top_builddir)/$(CLASSDIR)/gnu/java/util/prefs/gconf/%.class
 	$(JAVAH) -o $@ gnu.java.util.prefs.gconf.$*
 
-$(top_srcdir)/include/gnu_java_net_VMPlainDatagramSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
-	$(JAVAH) -o $@ gnu.java.net.VMPlainDatagramSocketImpl
 $(top_srcdir)/include/gnu_java_net_VMPlainSocketImpl.h: $(top_srcdir)/vm/reference/gnu/java/net/VMPlainSocketImpl.java
 	$(JAVAH) -o $@ gnu.java.net.VMPlainSocketImpl
 $(top_srcdir)/include/gnu_java_net_local_LocalSocketImpl.h: $(top_srcdir)/gnu/java/net/local/LocalSocketImpl.java
Index: include/gnu_java_net_VMPlainDatagramSocketImpl.h
===================================================================
RCS file: include/gnu_java_net_VMPlainDatagramSocketImpl.h
diff -N include/gnu_java_net_VMPlainDatagramSocketImpl.h
--- include/gnu_java_net_VMPlainDatagramSocketImpl.h	19 Mar 2006 23:17:16 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-
-#ifndef __gnu_java_net_VMPlainDatagramSocketImpl__
-#define __gnu_java_net_VMPlainDatagramSocketImpl__
-
-#include <jni.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_bind (JNIEnv *env, jclass, jobject, jint, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_create (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_connect (JNIEnv *env, jclass, jobject, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeSendTo (JNIEnv *env, jclass, jobject, jobject, jint, jbyteArray, jint, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeReceive (JNIEnv *env, jclass, jobject, jbyteArray, jint, jint, jbyteArray, jintArray, jintArray);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_setOption (JNIEnv *env, jclass, jobject, jint, jobject);
-JNIEXPORT jobject JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_getOption (JNIEnv *env, jclass, jobject, jint);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_close (JNIEnv *env, jclass, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_join (JNIEnv *env, jclass, jobject, jobject);
-JNIEXPORT void JNICALL Java_gnu_java_net_VMPlainDatagramSocketImpl_leave (JNIEnv *env, jclass, jobject, jobject);
-#undef gnu_java_net_VMPlainDatagramSocketImpl_IP_TTL
-#define gnu_java_net_VMPlainDatagramSocketImpl_IP_TTL 7777L
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __gnu_java_net_VMPlainDatagramSocketImpl__ */
Index: native/jni/java-net/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/Makefile.am,v
retrieving revision 1.18
diff -u -r1.18 Makefile.am
--- native/jni/java-net/Makefile.am	21 Aug 2006 23:34:45 -0000	1.18
+++ native/jni/java-net/Makefile.am	9 Oct 2006 23:58:11 -0000
@@ -13,7 +13,6 @@
 			java_net_VMInetAddress.c \
 			java_net_VMNetworkInterface.c \
 			java_net_VMURLConnection.c \
-			gnu_java_net_VMPlainDatagramSocketImpl.c \
                         gnu_java_net_VMPlainSocketImpl.c \
 			$(local_sources)
 
Index: native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c
===================================================================
RCS file: native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c
diff -N native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c
--- native/jni/java-net/gnu_java_net_VMPlainDatagramSocketImpl.c	21 Aug 2006 23:34:45 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,406 +0,0 @@
-/* VMPlainDatagramSocketImpl.c - Native methods for PlainDatagramSocketImpl
-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
- 
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-/* do not move; needed here because of some macro definitions */
-#include <config.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <jni.h>
-#include <jcl.h>
-
-#include "cpnative.h"
-#include "cpnet.h"
-
-#include "javanet.h"
-
-#include "gnu_java_net_VMPlainDatagramSocketImpl.h"
-
-/*
- * Note that most of the functions in this module simply redirect to another
- * internal function.  Why?  Because many of these functions are shared
- * with PlainSocketImpl. 
- */
-
-/*************************************************************************/
-
-/*
- * Creates a new datagram socket
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_create(JNIEnv *env,
-						   jclass klass __attribute__ ((__unused__))
-						   , jobject obj)
-{
-
-#ifndef WITHOUT_NETWORK
-  _javanet_create(env, obj, 0);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Close the socket.
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_close(JNIEnv *env,
-						  jclass klass __attribute__ ((__unused__)),
-						  jobject obj)
-{
-
-#ifndef WITHOUT_NETWORK
-  _javanet_close(env, obj, 0);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Connects to the specified destination.
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_connect(JNIEnv *env,
-						    jclass klass __attribute__ ((__unused__)),
-						    jobject obj,
-						    jobject addr, jint port)
-{
-#ifndef WITHOUT_NETWORK
-
-  _javanet_connect(env, obj, addr, port, 0);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * This method binds the specified address to the specified local port.
- * Note that we have to set the local address and local port public instance 
- * variables. 
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_bind(JNIEnv *env,
-						 jclass klass __attribute__ ((__unused__)),
-						 jobject obj,
-						 jint port, jobject addr)
-{
-
-#ifndef WITHOUT_NETWORK
-  _javanet_bind(env, obj, addr, port, 0);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * This method sets the specified option for a socket
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_setOption(JNIEnv *env,
-						      jclass klass __attribute__ ((__unused__)),
-						      jobject obj, 
-						      jint option_id,
-						      jobject val)
-{
-
-#ifndef WITHOUT_NETWORK
-  _javanet_set_option(env, obj, option_id, val);
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * This method sets the specified option for a socket
- */
-JNIEXPORT jobject JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_getOption(JNIEnv *env,
-						      jclass klass __attribute__ ((__unused__)),
-						      jobject obj, 
-						      jint option_id)
-{
-
-#ifndef WITHOUT_NETWORK
-  return(_javanet_get_option(env, obj, option_id));
-#else /* not WITHOUT_NETWORK */
-  return NULL;
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Reads a buffer from a remote host
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeReceive(JNIEnv     *env,
-                                                          jclass     klass __attribute__ ((__unused__)),
-                                                          jobject    obj,
-                                                          jbyteArray arr,
-                                                          jint       offset,
-                                                          jint       length,
-                                                          jbyteArray receivedFromAddress,
-                                                          jintArray  receivedFromPort,
-                                                          jintArray  receivedLength)
-{
-#ifndef WITHOUT_NETWORK
-  jint          *port, *bytes_read;
-  cpnet_address *addr;
-  jbyte          *addressBytes;
-
-  addr = 0;
-    
-  port = (jint*)(*env)->GetIntArrayElements(env, receivedFromPort, NULL);
-  if (port == NULL)
-    {
-      JCL_ThrowException(env, IO_EXCEPTION, "Internal error: could not access receivedFromPort array");
-      return;
-    }
-  
-  bytes_read = (jint*)(*env)->GetIntArrayElements(env, receivedLength, NULL);
-  if (bytes_read == NULL)
-    {
-      (*env)->ReleaseIntArrayElements(env, receivedFromPort, (jint*)port, 0);
-      JCL_ThrowException(env, IO_EXCEPTION, "Internal error: could not access receivedLength array");
-      return;
-    }
-
-  /* Receive the packet */
-  /* should we try some sort of validation on the length? */
-  (*bytes_read) = _javanet_recvfrom(env, obj, arr, offset, length, &addr);
-
-  /* Special case the strange situation where the receiver didn't want any
-     bytes. */
-  if (length == 0 && (*bytes_read) == -1)
-    *bytes_read = 0;
-
-  if ((*bytes_read) == -1)
-    {
-      (*env)->ReleaseIntArrayElements(env, receivedFromPort, (jint*)port, 0);
-      (*env)->ReleaseIntArrayElements(env, receivedLength, (jint*)bytes_read, 0);
-      JCL_ThrowException(env, IO_EXCEPTION, "Internal error: receive");
-      return;
-    }
-
-  if ((*env)->ExceptionOccurred(env))
-    return;
-
-  *port = cpnet_addressGetPort (addr);
-  
-  /* Store the address */
-  addressBytes = (jbyte*)(*env)->GetPrimitiveArrayCritical(env, receivedFromAddress, NULL);
-  cpnet_IPV4AddressToBytes (addr, addressBytes);
-  (*env)->ReleasePrimitiveArrayCritical(env, receivedFromAddress, addressBytes, 0);
-  
-  cpnet_freeAddress (env, addr);
-  
-  (*env)->ReleaseIntArrayElements(env, receivedFromPort, (jint*)port, 0);
-  (*env)->ReleaseIntArrayElements(env, receivedLength, (jint*)bytes_read, 0);
-
-  DBG("PlainDatagramSocketImpl.receive(): Received packet\n");
-  
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Writes a buffer to the remote host
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_nativeSendTo(JNIEnv  *env,
-                                                         jclass  klass __attribute__ ((__unused__)),
-                                                         jobject obj, 
-                                                         jobject addr,
-                                                         jint    port,
-                                                         jarray  buf, 
-                                                         jint    offset,
-                                                         jint    len)
-{
-#ifndef WITHOUT_NETWORK
-  cpnet_address *netAddress;
-
-  /* check if address given, tr 7.3.2005 */
-  if (addr != NULL )
-    {
-      netAddress = _javanet_get_ip_netaddr(env, addr);
-      if ((*env)->ExceptionOccurred(env))
-        {	  
-          return;
-        }
-      if (port == 0)
-	{
-	  JCL_ThrowException(env, IO_EXCEPTION,
-			     "Invalid port number");
-	  cpnet_freeAddress(env, netAddress);
-	  return;
-	}
-      cpnet_addressSetPort (netAddress, port);
-    }
-  else
-    {
-      netAddress = NULL;
-    }
-
-  DBG("PlainDatagramSocketImpl.sendto(): have addr\n");
-
-  _javanet_sendto(env, obj, buf, offset, len, netAddress);
-  if (netAddress != NULL)
-    cpnet_freeAddress(env, netAddress);
-  if ((*env)->ExceptionOccurred(env))
-    {
-      return;
-    }
-
-  DBG("PlainDatagramSocketImpl.sendto(): finished\n");
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Joins a multicast group
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_join(JNIEnv *env,
-						 jclass klass __attribute__ ((__unused__)),
-						 jobject obj, 
-						 jobject addr)
-{
-#ifndef WITHOUT_NETWORK
-  cpnet_address *netAddress;
-  int  fd;
-  int  result;
-
-  /* check if address given, tr 7.3.2005 */
-  if (addr != NULL)
-    {
-      netAddress = _javanet_get_ip_netaddr(env, addr);
-      if ((*env)->ExceptionOccurred(env))
-        {
-          JCL_ThrowException(env, IO_EXCEPTION, "Internal error");
-          return;
-        }
-    }
-  else
-    {
-      netAddress = NULL;
-    }
-
-  fd = _javanet_get_int_field(env, obj, "native_fd");
-  if ((*env)->ExceptionOccurred(env))
-    {
-      JCL_ThrowException(env, IO_EXCEPTION, "Internal error");
-      return;
-    }
-
-  DBG("PlainDatagramSocketImpl.join(): have native fd\n");
-
-  result = cpnet_addMembership (env, fd, netAddress);
-  if (result != CPNATIVE_OK)
-    {
-      JCL_ThrowException(env, IO_EXCEPTION, 
-			 cpnative_getErrorString (result));
-      return;
-    }
-
-  DBG("PlainDatagramSocketImpl.join(): finished\n");
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
-/*************************************************************************/
-
-/*
- * Leaves a multicast group
- */
-JNIEXPORT void JNICALL
-Java_gnu_java_net_VMPlainDatagramSocketImpl_leave(JNIEnv *env,
-						  jclass klass __attribute__ ((__unused__)),
-						  jobject obj, 
-						  jobject addr)
-{
-#ifndef WITHOUT_NETWORK
-  cpnet_address *netAddress;
-  int  fd;
-  int  result;
-
-  /* check if address given, tr 7.3.2005 */
-  if (addr != NULL)
-    {
-      netAddress = _javanet_get_ip_netaddr(env, addr);
-      if ((*env)->ExceptionOccurred(env))
-        {
-          JCL_ThrowException(env, IO_EXCEPTION, "Internal error");
-          return;
-        }
-    }
-  else
-    {
-      netAddress = 0;
-    }
-
-  fd = _javanet_get_int_field(env, obj, "native_fd");
-  if ((*env)->ExceptionOccurred(env))
-    {
-      JCL_ThrowException(env, IO_EXCEPTION, "Internal error"); 
-      return; 
-    }
-
-  DBG("PlainDatagramSocketImpl.leave(): have native fd\n");
-
-  result = cpnet_dropMembership (env, fd, netAddress);
-  if (result != CPNATIVE_OK)
-    {
-      JCL_ThrowException(env, IO_EXCEPTION, cpnative_getErrorString (result));
-      return;
-    }
-
-  DBG("PlainDatagramSocketImpl.leave(): finished\n");
-#else /* not WITHOUT_NETWORK */
-#endif /* not WITHOUT_NETWORK */
-}
-
Index: native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c,v
retrieving revision 1.11
diff -u -r1.11 gnu_java_net_VMPlainSocketImpl.c
--- native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c	9 Oct 2006 11:10:41 -0000	1.11
+++ native/jni/java-net/gnu_java_net_VMPlainSocketImpl.c	9 Oct 2006 23:58:11 -0000
@@ -56,16 +56,13 @@
 #include <jni.h>
 #include <jcl.h>
 
-/* #include "javanet.h" */
+#include "cpnative.h"
+#include "cpnet.h"
+#include "javanet.h"
 
 #include "gnu_java_net_VMPlainSocketImpl.h"
 
-#define IO_EXCEPTION "java/io/IOException"
-#define SOCKET_EXCEPTION "java/net/SocketException"
-#define BIND_EXCEPTION "java/net/BindException"
-
-#define THROW_NO_NETWORK(env) JCL_ThrowException (env, "java/lang/InternalError", "this platform not configured for network support") 
-
+#define THROW_NO_NETWORK(env) JCL_ThrowException (env, "java/lang/InternalError", "this platform not configured for network support")
 
 /*
  * Class:     gnu_java_net_VMPlainSocketImpl
@@ -158,7 +155,10 @@
 }
 
 
-/* These constants are also defined in java/net/SocketOptions.java */
+/* These constants are also defined in java/net/SocketOptions.java.
+ * Except for CPNET_IP_TTL which is defined in 
+ * vm/reference/gnu/java/net/VMPlainSocketImpl.java .
+ */
 enum java_sockopt {
   CPNET_SO_KEEPALIVE = 0x8,
   CPNET_SO_LINGER = 0x80,
@@ -173,7 +173,8 @@
   CPNET_IP_MULTICAST_IF = 0x10,
   CPNET_IP_MULTICAST_IF2 = 0x1F,
   CPNET_IP_MULTICAST_LOOP = 0x12,
-  CPNET_IP_TOS = 0x03
+  CPNET_IP_TOS = 0x03,
+  CPNET_IP_TTL = 0x1E61
 };
 
 
@@ -195,7 +196,9 @@
   struct timeval _timeo;
   void *optval = (void *) &_value;
   socklen_t optlen = sizeof (int);
-
+  
+  int isIPv6 = get_family(fd) == AF_INET;
+  
   switch (joption)
     {
     case CPNET_IP_MULTICAST_LOOP:
@@ -256,6 +259,11 @@
       optname = IP_TOS;
       break;
 
+    case CPNET_IP_TTL:
+      level = IPPROTO_IP;
+      optname = IP_TTL;
+      break;
+
     case CPNET_SO_BINDADDR:
     case CPNET_IP_MULTICAST_IF:
     case CPNET_IP_MULTICAST_IF2:
@@ -339,6 +347,11 @@
       optname = IP_TOS;
       break;
 
+    case CPNET_IP_TTL:
+      level = IPPROTO_IP;
+      optname = IP_TTL;
+      break;
+
     case CPNET_SO_BINDADDR:
     case CPNET_IP_MULTICAST_IF:
     case CPNET_IP_MULTICAST_IF2:
@@ -357,6 +370,85 @@
   return value;
 }
 
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface (JNIEnv *env,
+                                                           jclass c __attribute__((unused)),
+                                                           jint fd,
+                                                           jint optionId __attribute__((unused)),
+                                                           jobject addr)
+{
+  int result;
+  cpnet_address *cpaddr = _javanet_get_ip_netaddr (env, addr);
+
+  if ((*env)->ExceptionOccurred (env))
+    return;
+
+  result = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+                      (struct sockaddr *) cpaddr->data, cpaddr->len);
+
+  cpnet_freeAddress (env, cpaddr);
+  
+  if (result == -1)
+    JCL_ThrowException (env, SOCKET_EXCEPTION, cpnative_getErrorString (errno));
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_setMulticastInterface6 (JNIEnv *env,
+                                                           jclass c __attribute__((unused)),
+                                                           jint fd,
+                                                           jint optionId __attribute__((unused)),
+                                                           jobject addr)
+{
+#ifdef HAVE_SETSOCKOPT
+#ifdef HAVE_INET6	
+  int result;
+  cpnet_address *cpaddr = _javanet_get_ip_netaddr (env, addr);
+
+  if ((*env)->ExceptionOccurred (env))
+    return;
+
+  result = setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                      (struct sockaddr *) cpaddr->data, cpaddr->len);
+
+  cpnet_freeAddress (env, cpaddr);
+  
+  if (result == -1)
+    JCL_ThrowException (env, SOCKET_EXCEPTION, cpnative_getErrorString (errno));
+#else
+  (void) fd;
+  JCL_ThrowException (env, "java/lang/InternalError",
+                      "IPv6 support not available");
+#endif /* HAVE_INET6 */
+#else
+  (void) fd;
+  JCL_ThrowException (env, "java/lang/InternalError",
+                      "socket options not supported");
+#endif /* HAVE_SETSOCKOPT */
+}
+
+JNIEXPORT jobject JNICALL
+Java_gnu_java_net_VMPlainSocketImpl_getMulticastInterface (JNIEnv *env,
+                                                           jclass c __attribute__((unused)),
+                                                           jint fd,
+                                                           jint optionId __attribute__((unused)))
+{
+  jobject obj;
+  cpnet_address *cpaddr;
+  int result = cpnet_getMulticastIF (env, fd, &cpaddr);
+ 
+  if (result != CPNATIVE_OK)
+    {
+      JCL_ThrowException (env, SOCKET_EXCEPTION,
+                          cpnative_getErrorString (result));
+      return (0);
+    }
+
+  obj = _javanet_create_inetaddress (env, cpaddr);
+  cpnet_freeAddress (env, cpaddr);
+
+  return obj;
+}
+
 
 /*
  * Class:     gnu_java_net_VMPlainSocketImpl
Index: native/jni/java-nio/gnu_java_nio_VMChannel.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c,v
retrieving revision 1.4
diff -u -r1.4 gnu_java_nio_VMChannel.c
--- native/jni/java-nio/gnu_java_nio_VMChannel.c	17 Sep 2006 22:49:52 -0000	1.4
+++ native/jni/java-nio/gnu_java_nio_VMChannel.c	9 Oct 2006 23:58:11 -0000
@@ -64,7 +64,9 @@
 #include <fcntl.h>
 #endif /* HAVE_FCNTL_H */
 
+#define CONNECT_EXCEPTION "java/net/ConnectException"
 #define IO_EXCEPTION "java/io/IOException"
+#define SOCKET_EXCEPTION "java/net/SocketException"
 #define INTERRUPTED_IO_EXCEPTION "java/io/InterruptedIOException"
 #define NON_READABLE_CHANNEL_EXCEPTION "java/nio/channels/NonReadableChannelException"
 #define NON_WRITABLE_CHANNEL_EXCEPTION "java/nio/channels/NonWritableChannelException"
@@ -119,7 +121,7 @@
 /*   NIODBG("name: %s; sig: %s", name, sig); */
   if (mid == NULL)
     {
-  	  JCL_ThrowException(env, "java/lang/InternalError", name);
+      JCL_ThrowException(env, "java/lang/InternalError", name);
       return NULL;
     }
   
@@ -973,7 +975,8 @@
 
   if ((*env)->GetArrayLength (env, addr) != 4)
     {
-      JCL_ThrowException (env, "java/io/IOException", "expecting 4-byte address");
+      JCL_ThrowException (env, SOCKET_EXCEPTION,
+                          "expecting 4-byte address");
       return JNI_FALSE;
     }
 
@@ -984,7 +987,7 @@
       origflags = fcntl (fd, F_GETFL, 0);
       if (origflags == -1)
         {
-          JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
       /* Set nonblocking mode, if not already set. */
@@ -993,7 +996,7 @@
           flags = origflags | O_NONBLOCK;
           if (fcntl (fd, F_SETFL, flags) == -1)
             {
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
         }
@@ -1022,7 +1025,7 @@
           if (fcntl (fd, F_SETFL, origflags) == -1)
             {
               /* oops */
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
         }
@@ -1033,7 +1036,7 @@
           ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
           if (ret == -1)
             {
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
           if (ret == 0) /* connect timed out */
@@ -1046,13 +1049,13 @@
         }
       else if (ECONNREFUSED == errno)
         {
-          JCL_ThrowException (env, "java/net/ConnectException",
+          JCL_ThrowException (env, CONNECT_EXCEPTION,
                               strerror (errno));
           return JNI_FALSE;
         }
       else
         {
-          JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
     }
@@ -1063,13 +1066,13 @@
         return JNI_FALSE;
       else if (ECONNREFUSED == errno)
         {
-          JCL_ThrowException (env, "java/net/ConnectException",
+          JCL_ThrowException (env, CONNECT_EXCEPTION,
                               strerror (errno));
           return JNI_FALSE;
         }
       else
         {
-          JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
     }
@@ -1080,7 +1083,7 @@
   (void) addr;
   (void) port;
   (void) timeout;
-  JCL_ThrowException (env, IO_EXCEPTION, "connect not supported");
+  JCL_ThrowException (env, SOCKET_EXCEPTION, "connect not supported");
   return JNI_FALSE;
 #endif /* HAVE_CONNECT */
 }
@@ -1109,7 +1112,7 @@
       origflags = fcntl (fd, F_GETFL, 0);
       if (origflags == -1)
         {
-          JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
       /* Set nonblocking mode, if not already set. */
@@ -1118,7 +1121,7 @@
           flags = origflags | O_NONBLOCK;
           if (fcntl (fd, F_SETFL, flags) == -1)
             {
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
         }
@@ -1146,7 +1149,7 @@
           if (fcntl (fd, F_SETFL, origflags) == -1)
             {
               /* oops */
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
         }
@@ -1157,7 +1160,7 @@
           ret = cpnio_select (fd + 1, NULL, &wrfds, NULL, &timeo);
           if (ret == -1)
             {
-              JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+              JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
               return JNI_FALSE;
             }
           if (ret == 0) /* connect timed out */
@@ -1170,13 +1173,13 @@
         }
       else if (ECONNREFUSED == errno)
         {
-          JCL_ThrowException (env, "java/net/ConnectException",
+          JCL_ThrowException (env, CONNECT_EXCEPTION,
                               strerror (errno));
           return JNI_FALSE;
         }
       else
         {
-          JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
     }
@@ -1187,13 +1190,13 @@
         return JNI_FALSE;
       else if (ECONNREFUSED == errno)
         {
-          JCL_ThrowException (env, "java/net/ConnectException",
+          JCL_ThrowException (env, CONNECT_EXCEPTION,
                               strerror (errno));
           return JNI_FALSE;
         }
       else
         {
-          JCL_ThrowException (env, "java/io/IOException", strerror (errno));
+          JCL_ThrowException (env, SOCKET_EXCEPTION, strerror (errno));
           return JNI_FALSE;
         }
     }
@@ -1204,7 +1207,7 @@
   (void) addr;
   (void) port;
   (void) timeout;
-  JCL_ThrowException (env, IO_EXCEPTION, "IPv6 connect not supported");
+  JCL_ThrowException (env, SOCKET_EXCEPTION, "IPv6 connect not supported");
   return JNI_FALSE;
 #endif /* HAVE_CONNECT && HAVE_INET6 */
 }
Index: vm/reference/gnu/java/nio/VMChannel.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/gnu/java/nio/VMChannel.java,v
retrieving revision 1.4
diff -u -r1.4 VMChannel.java
--- vm/reference/gnu/java/nio/VMChannel.java	27 Sep 2006 21:30:44 -0000	1.4
+++ vm/reference/gnu/java/nio/VMChannel.java	9 Oct 2006 23:58:11 -0000
@@ -379,23 +379,37 @@
    * @throws IOException If an error occurs while connecting.
    */
   public boolean connect(InetSocketAddress saddr, int timeout)
-    throws IOException
+    throws SocketException
   {
+    int fd;
+
     InetAddress addr = saddr.getAddress();
+ 
+    // Translates an IOException into a SocketException to conform
+    // to the throws clause.
+    try
+      {
+        fd = nfd.getNativeFD();
+      }
+    catch (IOException ioe)
+      {
+        throw new SocketException(ioe.getMessage());
+      }
+
     if (addr instanceof Inet4Address)
-      return connect(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+      return connect(fd, addr.getAddress(), saddr.getPort(),
                      timeout);
     if (addr instanceof Inet6Address)
-      return connect6(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+      return connect6(fd, addr.getAddress(), saddr.getPort(),
                       timeout);
-    throw new IOException("unsupported internet address");
+    throw new SocketException("unsupported internet address");
   }
   
   private static native boolean connect(int fd, byte[] addr, int port, int timeout)
-    throws IOException;
+    throws SocketException;
   
   private static native boolean connect6(int fd, byte[] addr, int port, int timeout)
-    throws IOException;
+    throws SocketException;
   
   /**
    * Disconnect this channel, if it is a datagram socket. Disconnecting
Index: vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
===================================================================
RCS file: vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
diff -N vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java
--- vm/reference/gnu/java/net/VMPlainDatagramSocketImpl.java	12 Jan 2006 11:56:08 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,260 +0,0 @@
-/* PlainDatagramSocketImpl.java -- VM interface for DatagramSocket impl
-   Copyright (C) 2005 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
- 
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.net;
-
-import gnu.classpath.Configuration;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.net.SocketAddress;
-import java.net.SocketException;
-
-/**
- * The VM interface for [EMAIL PROTECTED] gnu.java.net.PlainDatagramSocketImpl}.
- *
- * @author Ingo Proetel ([EMAIL PROTECTED])
- * @author Roman Kennke ([EMAIL PROTECTED])
- */
-public final class VMPlainDatagramSocketImpl
-{
-  /**
-   * Option id for the IP_TTL (time to live) value.
-   */
-  static final int IP_TTL = 0x1E61; // 7777
-
-
-  // Static initializer to load native library
-  static
-  {
-    if (Configuration.INIT_LOAD_LIBRARY)
-      {
-        System.loadLibrary("javanet");
-      }
-  }
-  
-  /**
-   * Binds this socket to a particular port and interface
-   *
-   * @param socket the socket object
-   * @param port the port to bind to
-   * @param addr the address to bind to
-   *
-   * @throws SocketException If an error occurs
-   */  
-  static native void bind(PlainDatagramSocketImpl socket, int port,
-                          InetAddress addr) 
-    throws SocketException;
-
-  /**
-   * Creates a new datagram socket.
-   *
-   * @param socket the socket object
-   *
-   * @throws SocketException If an error occurs
-   */
-  static native void create(PlainDatagramSocketImpl socket)
-    throws SocketException;
-
-  /**
-   * Connects to the remote address and port specified as arguments.
-   *
-   * @param socket the socket object
-   * @param addr the remote address to connect to
-   * @param port the remote port to connect to
-   *
-   * @throws SocketException If an error occurs
-   */
-  static native void connect(PlainDatagramSocketImpl socket, InetAddress addr,
-                             int port)
-    throws SocketException;
-
-  /**
-   * Sends a packet of data to a remote host.
-   *
-   * @param socket the socket object
-   * @param packet the packet to send
-   *
-   * @throws IOException If an error occurs
-   */
-  static void send(PlainDatagramSocketImpl socket, DatagramPacket packet)
-    throws IOException
-  {
-    nativeSendTo(socket, packet.getAddress(), packet.getPort(),
-                 packet.getData(), packet.getOffset(), packet.getLength());
-  }
-
-
-  /**
-   * Sends a packet of data to a remote host.
-   *
-   * @param socket the socket object
-   * @param addr the address to send to
-   * @param port the port to send to 
-   * @param buf the buffer to send
-   * @param offset the offset of the data in the buffer to send
-   * @param len the length of the data to send
-   *
-   * @throws IOException If an error occurs
-   */
-  private static native void nativeSendTo(PlainDatagramSocketImpl socket,
-                                          InetAddress addr, int port,
-                                          byte[] buf, int offset, int len)
-    throws IOException;
-
-  /**
-   * Receives a UDP packet from the network
-   *
-   * @param socket the socket object
-   * @param packet the packet to fill in with the data received
-   *
-   * @throws IOException IOException If an error occurs
-   */
-  static void receive(PlainDatagramSocketImpl socket, DatagramPacket packet)
-    throws IOException
-  {
-    byte[] receiveFromAddress = new byte[4];
-    int[] receiveFromPort = new int[1];
-    int[] receivedLength = new int[1];
-
-    nativeReceive(socket, packet.getData(), packet.getOffset(),
-                  packet.getLength(),
-                  receiveFromAddress, receiveFromPort, receivedLength);
-
-    packet.setAddress(InetAddress.getByAddress(receiveFromAddress));
-    packet.setPort(receiveFromPort[0]);
-    packet.setLength(receivedLength[0]);
-  }
-
-  private static native void nativeReceive(PlainDatagramSocketImpl socket,
-                                           byte[] buf, int offset, int len,
-                                           byte[] receiveFromAddress,
-                                           int[] receiveFromPort,
-                                           int[] receivedLength)
-    throws IOException;
-
-  /**
-   * Sets the value of an option on the socket
-   *
-   * @param socket the socket object
-   * @param optionId the identifier of the option to set
-   * @param value the value of the option to set
-   *
-   * @exception SocketException If an error occurs
-   */
-  static native void setOption(PlainDatagramSocketImpl socket, int optionId,
-                               Object value)
-    throws SocketException;
-
-  /**
-   * Retrieves the value of an option on the socket.
-   *
-   * @param socket the socket object
-   * @param optionId the identifier of the option to retrieve
-   *
-   * @return the value of the option
-   *
-   * @throws SocketException if an error occurs
-   */
-  static native Object getOption(PlainDatagramSocketImpl socket, int optionId)
-    throws SocketException;
-
-  /**
-   * Closes the socket.
-   *
-   * @param socket the socket object
-   */
-  static native void close(PlainDatagramSocketImpl socket);
-
-  /**
-   * Joins a multicast group
-   *
-   * @param addr The group to join
-   *
-   * @exception IOException If an error occurs
-   */
-  static native void join(PlainDatagramSocketImpl socket, InetAddress addr)
-    throws IOException;
-
-  /**
-   * Leaves a multicast group
-   *
-   * @param addr The group to leave
-   *
-   * @exception IOException If an error occurs
-   */
-  static native void leave(PlainDatagramSocketImpl socket, InetAddress addr)
-    throws IOException;
-
-  /**
-   * Joins a multicast group.
-   *
-   * @param socket the socket object
-   * @param address the socket address
-   * @param netIf the network interface
-   *
-   * @throws IOException if I/O errors occur
-   */
-  static void joinGroup(PlainDatagramSocketImpl socket, SocketAddress address,
-                        NetworkInterface netIf)
-    throws IOException
-  {
-    throw new InternalError
-      ("PlainDatagramSocketImpl::joinGroup is not implemented");
-  }
-
-  /**
-   * Leaves a multicast group.
-   *
-   * @param socket the socket object
-   * @param address the socket address
-   * @param netIf the network interface
-   *
-   * @throws IOException if I/O errors occur
-   */
-  static void leaveGroup(PlainDatagramSocketImpl socket, SocketAddress address,
-                         NetworkInterface netIf)
-    throws IOException
-  {
-    throw new InternalError
-      ("PlainDatagramSocketImpl::leaveGroup is not implemented");
-  }
-
-}
Index: vm/reference/gnu/java/net/VMPlainSocketImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/vm/reference/gnu/java/net/VMPlainSocketImpl.java,v
retrieving revision 1.4
diff -u -r1.4 VMPlainSocketImpl.java
--- vm/reference/gnu/java/net/VMPlainSocketImpl.java	17 Sep 2006 07:31:43 -0000	1.4
+++ vm/reference/gnu/java/net/VMPlainSocketImpl.java	9 Oct 2006 23:58:11 -0000
@@ -61,6 +61,10 @@
  */
 public final class VMPlainSocketImpl
 {
+  /** Option id for time to live
+   */
+  private static final int CP_IP_TTL = 0x1E61;
+
   private final State nfd;
   
   /**
@@ -91,6 +95,41 @@
     return nfd;
   }
 
+  /** This method exists to hide the CP_IP_TTL value from
+   * higher levels.
+   *
+   * Always think of JNode ... :)
+   */
+  public void setTimeToLive(int ttl)
+    throws SocketException
+  {
+    try
+      {
+        setOption(nfd.getNativeFD(), CP_IP_TTL, ttl);
+      }
+    catch (IOException ioe)
+      {
+        SocketException se = new SocketException();
+        se.initCause(ioe);
+        throw se;
+      }
+  }
+
+  public int getTimeToLive()
+    throws SocketException
+  {
+    try
+      {
+        return getOption(nfd.getNativeFD(), CP_IP_TTL);
+      }
+    catch (IOException ioe)
+      {
+        SocketException se = new SocketException();
+        se.initCause(ioe);
+        throw se;
+      }
+  }
+
   public void setOption(int optionId, Object optionValue)
     throws SocketException
   {
@@ -118,6 +157,38 @@
   private static native void setOption(int fd, int id, int value)
     throws SocketException;
 
+  public void setMulticastInterface(int optionId, InetAddress addr)
+    throws SocketException
+  {
+    try
+      {
+        if (addr instanceof Inet4Address)
+          setMulticastInterface(nfd.getNativeFD(), optionId, (Inet4Address) addr);
+        else if (addr instanceof Inet6Address)
+          setMulticastInterface6(nfd.getNativeFD(), optionId, (Inet6Address) addr);
+        else
+          throw new SocketException("Unknown address format: " + addr);
+      }
+    catch (SocketException se)
+      {
+        throw se;
+      }
+    catch (IOException ioe)
+      {
+        SocketException se = new SocketException();
+        se.initCause(ioe);
+        throw se;
+      }
+  }
+
+  private static native void setMulticastInterface(int fd,
+                                                   int optionId,
+                                                   Inet4Address addr);
+
+  private static native void setMulticastInterface6(int fd,
+                                                    int optionId,
+                                                    Inet6Address addr);
+
   /**
    * Get a socket option. This implementation is only required to support
    * socket options that are boolean values, which include:
@@ -178,6 +249,33 @@
   }
   
   private static native int getOption(int fd, int id) throws SocketException;
+
+  /**
+   * Returns an Inet4Address or Inet6Address instance belonging to the
+   * interface which is set as the multicast interface.
+   *
+   * The optionId is provided to make it possible that the native
+   * implementation may do something different depending on whether
+   * the value is SocketOptions.IP_MULTICAST_IF or 
+   * SocketOptions.IP_MULTICAST_IF2.
+   */
+  public InetAddress getMulticastInterface(int optionId)
+    throws SocketException
+  {
+    try
+      {
+        return getMulticastInterface(nfd.getNativeFD(), optionId);
+      }
+    catch (IOException ioe)
+      {
+        SocketException se = new SocketException();
+        se.initCause(ioe);
+        throw se;
+      }
+  }
+
+  private static native InetAddress getMulticastInterface(int fd,
+                                                          int optionId);
   
   /**
    * Binds this socket to the given local address and port.
@@ -402,4 +500,4 @@
         }
     }
   }
-}
\ No newline at end of file
+}
Index: NEWS
===================================================================
RCS file: /cvsroot/classpath/classpath/NEWS,v
retrieving revision 1.169
diff -u -r1.169 NEWS
--- NEWS	20 Sep 2006 22:35:55 -0000	1.169
+++ NEWS	9 Oct 2006 23:58:11 -0000
@@ -39,11 +39,13 @@
 * gnu.java.nio.VMPipe has been similarly changed.
 * gnu.java.net.VMPlainSocketImpl has been changed to remove some
   functionality now provided by VMChannel; datagram socket-specific
-  methods have also been moved here, deprecating
-  VMPlainDatagramSocketImpl.
+  methods have also been moved here, deprecating VMPlainDatagramSocketImpl.
+* gnu.java.net.VMPlainDatagramSocketImpl removed.
 
 New in release 0.92 (Aug 9, 2006)
 
+* GConf is used as a backend for java.util.prefs. GNU Classpath 
+  thanks to Mario Torre for this contribution!
 * libjawtgnu.so has been renamed libjawt.so for binary compatibility.
   libjawt.so should be installed in a VM-specific directory rather
   than directly in /usr/lib.  Proprietary VMs put their libjawt.so

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to