This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Moving java.net.Plain*SocketImpl


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,


I wrote a patch to move java.net.Plain*SocketImpl and helper classes 
to gnu.java.net. The attached patch is also tested by Mohan Embar and 
Richard Earnshaw on their platforms (win32 and arm/newlib).

Ok to commit ?


Michael
- -- 
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/WgjUWSOgCCdjSDsRAlkmAJ9vg5dQ8wD6dNhsyYu9+Yo6djqpbQCdHKKx
z25TMsvHiQyCGxdzt4cl5EI=
=d1yc
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2130
diff -u -b -B -r1.2130 ChangeLog
--- ChangeLog	31 Aug 2003 16:52:13 -0000	1.2130
+++ ChangeLog	6 Sep 2003 16:09:07 -0000
@@ -1,3 +1,39 @@
+2003-09-06  Michael Koch  <konqueror@gmx.de>
+
+	* java/net/DatagramSocket.java,
+	java/net/MulticastSocket.java,
+	java/net/ServerSocket.java,
+	java/net/Socket.java:
+	Use gnu.java.net.Plain*SocketImpl instead of
+	java.net.PlainSocketImpl.
+	* java/net/PlainDatagramSocketImpl.java,
+	java/net/PlainSocketImpl.java,
+	java/net/SocketInputStream.java,
+	java/net/SocketOutputStream.java,
+	java/net/natPlainDatagramSocketImplNoNet.cc,
+	java/net/natPlainDatagramSocketImplPosix.cc,
+	java/net/natPlainDatagramSocketImplWin32.cc,
+	java/net/natPlainSocketImplNoNet.cc,
+	java/net/natPlainSocketImplPosix.cc,
+	java/net/natPlainSocketImplWin32.cc:
+	Removed.
+	* gnu/java/net/PlainDatagramSocketImpl.java,
+	gnu/java/net/PlainSocketImpl.java,
+	gnu/java/net/SocketInputStream.java,
+	gnu/java/net/SocketOutputStream.java,
+	gnu/java/net/natPlainDatagramSocketImplNoNet.cc,
+	gnu/java/net/natPlainDatagramSocketImplPosix.cc,
+	gnu/java/net/natPlainDatagramSocketImplWin32.cc,
+	gnu/java/net/natPlainSocketImplNoNet.cc,
+	gnu/java/net/natPlainSocketImplPosix.cc,
+	gnu/java/net/natPlainSocketImplWin32.cc:
+	New files (moved from java/net).
+	* configure.in: Create links for gnu/java/net/natPlain*SocketImpl.cc
+	instead of java/net/natPlain*SocketImpl.cc.
+	* configure: Regenerated.
+	* Makefile.am: Moved files from java/net to gnu/java/net.
+	* Makefile.in: Regenerated.
+
 2003-08-31  Ingo Proetel  <proetel@aicas.com>
 
 	* java/util/logging/Logger.java: provide class and method information
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.319
diff -u -b -B -r1.319 Makefile.am
--- Makefile.am	29 Aug 2003 03:11:02 -0000	1.319
+++ Makefile.am	6 Sep 2003 16:09:07 -0000
@@ -2136,6 +2136,8 @@
 gnu/java/locale/LocaleInformation_zh_SG.java \
 gnu/java/locale/LocaleInformation_zh_TW.java \
 gnu/java/math/MPN.java \
+gnu/java/net/PlainDatagramSocketImpl.java \
+gnu/java/net/PlainSocketImpl.java \
 gnu/java/nio/DatagramChannelImpl.java \
 gnu/java/nio/FileLockImpl.java \
 gnu/java/nio/PipeImpl.java \
@@ -2232,8 +2234,6 @@
 java/net/NetworkInterface.java \
 java/net/NoRouteToHostException.java \
 java/net/PasswordAuthentication.java \
-java/net/PlainDatagramSocketImpl.java \
-java/net/PlainSocketImpl.java \
 java/net/PortUnreachableException.java \
 java/net/ProtocolException.java	\
 java/net/ServerSocket.java \
@@ -2604,6 +2604,8 @@
 gnu/gcj/runtime/natStringBuffer.cc \
 gnu/gcj/runtime/natVMClassLoader.cc \
 gnu/java/awt/natEmbeddedWindow.cc \
+gnu/java/net/natPlainDatagramSocketImpl.cc \
+gnu/java/net/natPlainSocketImpl.cc \
 gnu/java/nio/natFileLockImpl.cc \
 gnu/java/nio/natSelectorImpl.cc \
 java/io/natFile.cc \
@@ -2632,8 +2634,6 @@
 java/lang/reflect/natProxy.cc \
 java/net/natNetworkInterface.cc \
 java/net/natInetAddress.cc \
-java/net/natPlainDatagramSocketImpl.cc \
-java/net/natPlainSocketImpl.cc \
 java/nio/natDirectByteBufferImpl.cc \
 java/nio/channels/natFileChannelImpl.cc \
 java/text/natCollator.cc \
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.in,v
retrieving revision 1.343
diff -u -b -B -r1.343 Makefile.in
--- Makefile.in	29 Aug 2003 03:11:02 -0000	1.343
+++ Makefile.in	6 Sep 2003 16:09:08 -0000
@@ -1891,6 +1891,8 @@
 gnu/java/locale/LocaleInformation_zh_SG.java \
 gnu/java/locale/LocaleInformation_zh_TW.java \
 gnu/java/math/MPN.java \
+gnu/java/net/PlainDatagramSocketImpl.java \
+gnu/java/net/PlainSocketImpl.java \
 gnu/java/nio/DatagramChannelImpl.java \
 gnu/java/nio/FileLockImpl.java \
 gnu/java/nio/PipeImpl.java \
@@ -1987,8 +1989,6 @@
 java/net/NetworkInterface.java \
 java/net/NoRouteToHostException.java \
 java/net/PasswordAuthentication.java \
-java/net/PlainDatagramSocketImpl.java \
-java/net/PlainSocketImpl.java \
 java/net/PortUnreachableException.java \
 java/net/ProtocolException.java	\
 java/net/ServerSocket.java \
@@ -2358,6 +2358,8 @@
 gnu/gcj/runtime/natStringBuffer.cc \
 gnu/gcj/runtime/natVMClassLoader.cc \
 gnu/java/awt/natEmbeddedWindow.cc \
+gnu/java/net/natPlainDatagramSocketImpl.cc \
+gnu/java/net/natPlainSocketImpl.cc \
 gnu/java/nio/natFileLockImpl.cc \
 gnu/java/nio/natSelectorImpl.cc \
 java/io/natFile.cc \
@@ -2386,8 +2388,6 @@
 java/lang/reflect/natProxy.cc \
 java/net/natNetworkInterface.cc \
 java/net/natInetAddress.cc \
-java/net/natPlainDatagramSocketImpl.cc \
-java/net/natPlainSocketImpl.cc \
 java/nio/natDirectByteBufferImpl.cc \
 java/nio/channels/natFileChannelImpl.cc \
 java/text/natCollator.cc \
@@ -2535,20 +2535,21 @@
 gnu/gcj/runtime/natNameFinder.lo gnu/gcj/runtime/natSharedLibLoader.lo \
 gnu/gcj/runtime/natStackTrace.lo gnu/gcj/runtime/natStringBuffer.lo \
 gnu/gcj/runtime/natVMClassLoader.lo gnu/java/awt/natEmbeddedWindow.lo \
-gnu/java/nio/natFileLockImpl.lo gnu/java/nio/natSelectorImpl.lo \
-java/io/natFile.lo java/io/natFileDescriptor.lo \
-java/io/natObjectInputStream.lo java/io/natVMObjectStreamClass.lo \
-java/lang/natCharacter.lo java/lang/natClass.lo \
-java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \
-java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \
-java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \
+gnu/java/net/natPlainDatagramSocketImpl.lo \
+gnu/java/net/natPlainSocketImpl.lo gnu/java/nio/natFileLockImpl.lo \
+gnu/java/nio/natSelectorImpl.lo java/io/natFile.lo \
+java/io/natFileDescriptor.lo java/io/natObjectInputStream.lo \
+java/io/natVMObjectStreamClass.lo java/lang/natCharacter.lo \
+java/lang/natClass.lo java/lang/natClassLoader.lo \
+java/lang/natConcreteProcess.lo java/lang/natDouble.lo \
+java/lang/natFloat.lo java/lang/natMath.lo java/lang/natObject.lo \
+java/lang/natRuntime.lo java/lang/natString.lo \
 java/lang/natStringBuffer.lo java/lang/natSystem.lo \
 java/lang/natThread.lo java/lang/natVMSecurityManager.lo \
 java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \
 java/lang/reflect/natConstructor.lo java/lang/reflect/natField.lo \
 java/lang/reflect/natMethod.lo java/lang/reflect/natProxy.lo \
 java/net/natNetworkInterface.lo java/net/natInetAddress.lo \
-java/net/natPlainDatagramSocketImpl.lo java/net/natPlainSocketImpl.lo \
 java/nio/natDirectByteBufferImpl.lo \
 java/nio/channels/natFileChannelImpl.lo java/text/natCollator.lo \
 java/util/natResourceBundle.lo java/util/natTimeZone.lo \
@@ -2707,7 +2708,7 @@
 
 DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
 
-TAR = gtar
+TAR = tar
 GZIP_ENV = --best
 DIST_SUBDIRS =  @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
 DEP_FILES =  .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
@@ -3008,7 +3009,11 @@
 .deps/gnu/java/locale/LocaleInformation_zh_HK.P \
 .deps/gnu/java/locale/LocaleInformation_zh_SG.P \
 .deps/gnu/java/locale/LocaleInformation_zh_TW.P \
-.deps/gnu/java/math/MPN.P .deps/gnu/java/nio/DatagramChannelImpl.P \
+.deps/gnu/java/math/MPN.P .deps/gnu/java/net/PlainDatagramSocketImpl.P \
+.deps/gnu/java/net/PlainSocketImpl.P \
+.deps/gnu/java/net/natPlainDatagramSocketImpl.P \
+.deps/gnu/java/net/natPlainSocketImpl.P \
+.deps/gnu/java/nio/DatagramChannelImpl.P \
 .deps/gnu/java/nio/FileLockImpl.P .deps/gnu/java/nio/PipeImpl.P \
 .deps/gnu/java/nio/SelectionKeyImpl.P .deps/gnu/java/nio/SelectorImpl.P \
 .deps/gnu/java/nio/SelectorProviderImpl.P \
@@ -3508,8 +3513,6 @@
 .deps/java/net/NetPermission.P .deps/java/net/NetworkInterface.P \
 .deps/java/net/NoRouteToHostException.P \
 .deps/java/net/PasswordAuthentication.P \
-.deps/java/net/PlainDatagramSocketImpl.P \
-.deps/java/net/PlainSocketImpl.P \
 .deps/java/net/PortUnreachableException.P \
 .deps/java/net/ProtocolException.P .deps/java/net/ServerSocket.P \
 .deps/java/net/Socket.P .deps/java/net/SocketAddress.P \
@@ -3525,9 +3528,7 @@
 .deps/java/net/UnknownHostException.P \
 .deps/java/net/UnknownServiceException.P \
 .deps/java/net/natInetAddress.P .deps/java/net/natNetworkInterface.P \
-.deps/java/net/natPlainDatagramSocketImpl.P \
-.deps/java/net/natPlainSocketImpl.P .deps/java/nio/Buffer.P \
-.deps/java/nio/BufferOverflowException.P \
+.deps/java/nio/Buffer.P .deps/java/nio/BufferOverflowException.P \
 .deps/java/nio/BufferUnderflowException.P .deps/java/nio/ByteBuffer.P \
 .deps/java/nio/ByteBufferImpl.P .deps/java/nio/ByteOrder.P \
 .deps/java/nio/CharBuffer.P .deps/java/nio/CharBufferImpl.P \
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure.in,v
retrieving revision 1.167
diff -u -b -B -r1.167 configure.in
--- configure.in	21 Aug 2003 13:25:46 -0000	1.167
+++ configure.in	6 Sep 2003 16:09:08 -0000
@@ -272,13 +272,16 @@
 AC_LINK_FILES(java/lang/${PLATFORM}Process.java, java/lang/ConcreteProcess.java)
 AC_LINK_FILES(java/lang/nat${PLATFORM}Process.cc, java/lang/natConcreteProcess.cc)
 
-dnl Likewise for natInetAddress.cc, natNetworkInterface.cc, natPlainSocketImpl.cc
-dnl and natPlainDatagramSocketImpl.cc
+dnl Likewise for natInetAddress.cc and natNetworkInterface.cc.
 test -d java/net || mkdir java/net
 AC_LINK_FILES(java/net/natInetAddress${PLATFORMNET}.cc, java/net/natInetAddress.cc)
 AC_LINK_FILES(java/net/natNetworkInterface${PLATFORMNET}.cc, java/net/natNetworkInterface.cc)
-AC_LINK_FILES(java/net/natPlainSocketImpl${PLATFORMNET}.cc, java/net/natPlainSocketImpl.cc)
-AC_LINK_FILES(java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc, java/net/natPlainDatagramSocketImpl.cc)
+
+dnl Likewise for natPlainSocketImpl.cc and natPlainDatagramSocketImpl.ca.c
+test -d gnu/java || mkdir gnu/java
+test -d gnu/java/net || mkdir gnu/java/net
+AC_LINK_FILES(gnu/java/net/natPlainSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainSocketImpl.cc)
+AC_LINK_FILES(gnu/java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc, gnu/java/net/natPlainDatagramSocketImpl.cc)
 
 case "${host}" in
     *mingw*)
Index: configure
===================================================================
RCS file: /cvs/gcc/gcc/libjava/configure,v
retrieving revision 1.188
diff -u -b -B -r1.188 configure
--- configure	21 Aug 2003 13:25:46 -0000	1.188
+++ configure	6 Sep 2003 16:09:12 -0000
@@ -1631,7 +1631,7 @@
   if { (eval echo configure:1632: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then
     for file in conftest.*; do
       case $file in
-      *.c | *.o | *.obj) ;;
+      *.$ac_ext | *.c | *.o | *.obj) ;;
       *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;;
       esac
     done
@@ -3182,6 +3182,9 @@
 
 
 
+test -d gnu/java || mkdir gnu/java
+test -d gnu/java/net || mkdir gnu/java/net
+
 
 
 case "${host}" in
@@ -3213,7 +3216,7 @@
 # Uses ac_ vars as temps to allow command line to override cache and checks.
 # --without-x overrides everything else, but does not touch the cache.
 echo $ac_n "checking for X""... $ac_c" 1>&6
-echo "configure:3217: checking for X" >&5
+echo "configure:3220: checking for X" >&5
 
 # Check whether --with-x or --without-x was given.
 if test "${with_x+set}" = set; then
@@ -3275,12 +3278,12 @@
 
   # First, try using that file with no special directory specified.
 cat > conftest.$ac_ext <<EOF
-#line 3279 "configure"
+#line 3282 "configure"
 #include "confdefs.h"
 #include <$x_direct_test_include>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3284: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3287: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3349,14 +3352,14 @@
   ac_save_LIBS="$LIBS"
   LIBS="-l$x_direct_test_library $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3353 "configure"
+#line 3356 "configure"
 #include "confdefs.h"
 
 int main() {
 ${x_direct_test_function}()
 ; return 0; }
 EOF
-if { (eval echo configure:3360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3363: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   LIBS="$ac_save_LIBS"
 # We can link X programs with no special library path.
@@ -3462,17 +3465,17 @@
     case "`(uname -sr) 2>/dev/null`" in
     "SunOS 5"*)
       echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6
-echo "configure:3466: checking whether -R must be followed by a space" >&5
+echo "configure:3469: checking whether -R must be followed by a space" >&5
       ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries"
       cat > conftest.$ac_ext <<EOF
-#line 3469 "configure"
+#line 3472 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_nospace=yes
 else
@@ -3488,14 +3491,14 @@
       else
 	LIBS="$ac_xsave_LIBS -R $x_libraries"
 	cat > conftest.$ac_ext <<EOF
-#line 3492 "configure"
+#line 3495 "configure"
 #include "confdefs.h"
 
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:3499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3502: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_R_space=yes
 else
@@ -3527,7 +3530,7 @@
     # libraries were built with DECnet support.  And karl@cs.umb.edu says
     # the Alpha needs dnet_stub (dnet does not exist).
     echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6
-echo "configure:3531: checking for dnet_ntoa in -ldnet" >&5
+echo "configure:3534: checking for dnet_ntoa in -ldnet" >&5
 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3535,7 +3538,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3539 "configure"
+#line 3542 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3546,7 +3549,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:3550: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3568,7 +3571,7 @@
 
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6
-echo "configure:3572: checking for dnet_ntoa in -ldnet_stub" >&5
+echo "configure:3575: checking for dnet_ntoa in -ldnet_stub" >&5
 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3576,7 +3579,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldnet_stub  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3580 "configure"
+#line 3583 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3587,7 +3590,7 @@
 dnet_ntoa()
 ; return 0; }
 EOF
-if { (eval echo configure:3591: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3594: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3616,12 +3619,12 @@
     # The nsl library prevents programs from opening the X display
     # on Irix 5.2, according to dickey@clark.net.
     echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:3620: checking for gethostbyname" >&5
+echo "configure:3623: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3625 "configure"
+#line 3628 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -3644,7 +3647,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3651: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -3665,7 +3668,7 @@
 
     if test $ac_cv_func_gethostbyname = no; then
       echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6
-echo "configure:3669: checking for gethostbyname in -lnsl" >&5
+echo "configure:3672: checking for gethostbyname in -lnsl" >&5
 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3673,7 +3676,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3677 "configure"
+#line 3680 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3684,7 +3687,7 @@
 gethostbyname()
 ; return 0; }
 EOF
-if { (eval echo configure:3688: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3691: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3714,12 +3717,12 @@
     # -lsocket must be given before -lnsl if both are needed.
     # We assume that if connect needs -lnsl, so does gethostbyname.
     echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:3718: checking for connect" >&5
+echo "configure:3721: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3723 "configure"
+#line 3726 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -3742,7 +3745,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3746: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -3763,7 +3766,7 @@
 
     if test $ac_cv_func_connect = no; then
       echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6
-echo "configure:3767: checking for connect in -lsocket" >&5
+echo "configure:3770: checking for connect in -lsocket" >&5
 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3771,7 +3774,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3775 "configure"
+#line 3778 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3782,7 +3785,7 @@
 connect()
 ; return 0; }
 EOF
-if { (eval echo configure:3786: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3789: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3806,12 +3809,12 @@
 
     # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX.
     echo $ac_n "checking for remove""... $ac_c" 1>&6
-echo "configure:3810: checking for remove" >&5
+echo "configure:3813: checking for remove" >&5
 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3815 "configure"
+#line 3818 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char remove(); below.  */
@@ -3834,7 +3837,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3838: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_remove=yes"
 else
@@ -3855,7 +3858,7 @@
 
     if test $ac_cv_func_remove = no; then
       echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6
-echo "configure:3859: checking for remove in -lposix" >&5
+echo "configure:3862: checking for remove in -lposix" >&5
 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3863,7 +3866,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3867 "configure"
+#line 3870 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3874,7 +3877,7 @@
 remove()
 ; return 0; }
 EOF
-if { (eval echo configure:3878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3898,12 +3901,12 @@
 
     # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
     echo $ac_n "checking for shmat""... $ac_c" 1>&6
-echo "configure:3902: checking for shmat" >&5
+echo "configure:3905: checking for shmat" >&5
 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3907 "configure"
+#line 3910 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char shmat(); below.  */
@@ -3926,7 +3929,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:3930: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3933: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_shmat=yes"
 else
@@ -3947,7 +3950,7 @@
 
     if test $ac_cv_func_shmat = no; then
       echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6
-echo "configure:3951: checking for shmat in -lipc" >&5
+echo "configure:3954: checking for shmat in -lipc" >&5
 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3955,7 +3958,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lipc  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3959 "configure"
+#line 3962 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -3966,7 +3969,7 @@
 shmat()
 ; return 0; }
 EOF
-if { (eval echo configure:3970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3973: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -3999,7 +4002,7 @@
   # libraries we check for below, so use a different variable.
   #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
   echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6
-echo "configure:4003: checking for IceConnectionNumber in -lICE" >&5
+echo "configure:4006: checking for IceConnectionNumber in -lICE" >&5
 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4007,7 +4010,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lICE $X_EXTRA_LIBS $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4011 "configure"
+#line 4014 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4018,7 +4021,7 @@
 IceConnectionNumber()
 ; return 0; }
 EOF
-if { (eval echo configure:4022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4116,7 +4119,7 @@
 libsubdir=.libs
 
 echo $ac_n "checking for garbage collector to use""... $ac_c" 1>&6
-echo "configure:4120: checking for garbage collector to use" >&5
+echo "configure:4123: checking for garbage collector to use" >&5
 # Check whether --enable-java-gc or --disable-java-gc was given.
 if test "${enable_java_gc+set}" = set; then
   enableval="$enable_java_gc"
@@ -4168,7 +4171,7 @@
 
 
 echo $ac_n "checking for thread model used by GCC""... $ac_c" 1>&6
-echo "configure:4172: checking for thread model used by GCC" >&5
+echo "configure:4175: checking for thread model used by GCC" >&5
 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
 echo "$ac_t""$THREADS" 1>&6
 
@@ -4375,12 +4378,12 @@
    for ac_func in strerror ioctl select fstat open fsync sleep opendir
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4379: checking for $ac_func" >&5
+echo "configure:4382: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4384 "configure"
+#line 4387 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4403,7 +4406,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4407: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4410: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4430,12 +4433,12 @@
    for ac_func in gmtime_r localtime_r readdir_r getpwuid_r getcwd
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4434: checking for $ac_func" >&5
+echo "configure:4437: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4439 "configure"
+#line 4442 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4458,7 +4461,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4485,12 +4488,12 @@
    for ac_func in access stat mkdir rename rmdir unlink realpath utime chmod
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4489: checking for $ac_func" >&5
+echo "configure:4492: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4494 "configure"
+#line 4497 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4513,7 +4516,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4517: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4520: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4540,12 +4543,12 @@
    for ac_func in nl_langinfo setlocale
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4544: checking for $ac_func" >&5
+echo "configure:4547: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4549 "configure"
+#line 4552 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4568,7 +4571,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4595,12 +4598,12 @@
    for ac_func in inet_aton inet_addr
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4599: checking for $ac_func" >&5
+echo "configure:4602: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4604 "configure"
+#line 4607 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4623,7 +4626,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4627: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4630: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4650,12 +4653,12 @@
    for ac_func in inet_pton uname inet_ntoa
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4654: checking for $ac_func" >&5
+echo "configure:4657: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4659 "configure"
+#line 4662 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4678,7 +4681,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4682: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4685: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4705,12 +4708,12 @@
    for ac_func in fork execvp pipe sigaction ftruncate
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:4709: checking for $ac_func" >&5
+echo "configure:4712: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4714 "configure"
+#line 4717 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -4733,7 +4736,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4737: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4740: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -4761,17 +4764,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:4765: checking for $ac_hdr" >&5
+echo "configure:4768: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4770 "configure"
+#line 4773 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:4775: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:4778: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -4798,12 +4801,12 @@
 done
  
    echo $ac_n "checking for backtrace""... $ac_c" 1>&6
-echo "configure:4802: checking for backtrace" >&5
+echo "configure:4805: checking for backtrace" >&5
 if eval "test \"`echo '$''{'ac_cv_func_backtrace'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 4807 "configure"
+#line 4810 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char backtrace(); below.  */
@@ -4826,7 +4829,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:4830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4833: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_backtrace=yes"
 else
@@ -4870,7 +4873,7 @@
 
 
    echo $ac_n "checking for dladdr in -ldl""... $ac_c" 1>&6
-echo "configure:4874: checking for dladdr in -ldl" >&5
+echo "configure:4877: checking for dladdr in -ldl" >&5
 ac_lib_var=`echo dl'_'dladdr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -4878,7 +4881,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 4882 "configure"
+#line 4885 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -4889,7 +4892,7 @@
 dladdr()
 ; return 0; }
 EOF
-if { (eval echo configure:4893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:4896: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -4919,7 +4922,7 @@
 
 ac_safe=`echo "$ac_file" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_file""... $ac_c" 1>&6
-echo "configure:4923: checking for $ac_file" >&5
+echo "configure:4926: checking for $ac_file" >&5
 if eval "test \"`echo '$''{'ac_cv_file_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4977,7 +4980,7 @@
 
 
   echo $ac_n "checking for iconv""... $ac_c" 1>&6
-echo "configure:4981: checking for iconv" >&5
+echo "configure:4984: checking for iconv" >&5
 if eval "test \"`echo '$''{'am_cv_func_iconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -4985,7 +4988,7 @@
     am_cv_func_iconv="no, consider installing GNU libiconv"
     am_cv_lib_iconv=no
     cat > conftest.$ac_ext <<EOF
-#line 4989 "configure"
+#line 4992 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <iconv.h>
@@ -4995,7 +4998,7 @@
        iconv_close(cd);
 ; return 0; }
 EOF
-if { (eval echo configure:4999: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_func_iconv=yes
 else
@@ -5007,7 +5010,7 @@
       am_save_LIBS="$LIBS"
       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
       cat > conftest.$ac_ext <<EOF
-#line 5011 "configure"
+#line 5014 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <iconv.h>
@@ -5017,7 +5020,7 @@
          iconv_close(cd);
 ; return 0; }
 EOF
-if { (eval echo configure:5021: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_lib_iconv=yes
         am_cv_func_iconv=yes
@@ -5038,13 +5041,13 @@
 EOF
 
     echo $ac_n "checking for iconv declaration""... $ac_c" 1>&6
-echo "configure:5042: checking for iconv declaration" >&5
+echo "configure:5045: checking for iconv declaration" >&5
     if eval "test \"`echo '$''{'am_cv_proto_iconv'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
       cat > conftest.$ac_ext <<EOF
-#line 5048 "configure"
+#line 5051 "configure"
 #include "confdefs.h"
 
 #include <stdlib.h>
@@ -5063,7 +5066,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5067: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5070: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   am_cv_proto_iconv_arg1=""
 else
@@ -5092,19 +5095,19 @@
 
    if test $ac_cv_header_locale_h = yes; then
     echo $ac_n "checking for LC_MESSAGES""... $ac_c" 1>&6
-echo "configure:5096: checking for LC_MESSAGES" >&5
+echo "configure:5099: checking for LC_MESSAGES" >&5
 if eval "test \"`echo '$''{'am_cv_val_LC_MESSAGES'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5101 "configure"
+#line 5104 "configure"
 #include "confdefs.h"
 #include <locale.h>
 int main() {
 return LC_MESSAGES
 ; return 0; }
 EOF
-if { (eval echo configure:5108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   am_cv_val_LC_MESSAGES=yes
 else
@@ -5125,12 +5128,12 @@
     fi
   fi
    echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:5129: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:5132: checking whether struct tm is in sys/time.h or time.h" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5134 "configure"
+#line 5137 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <time.h>
@@ -5138,7 +5141,7 @@
 struct tm *tp; tp->tm_sec;
 ; return 0; }
 EOF
-if { (eval echo configure:5142: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5145: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm=time.h
 else
@@ -5159,12 +5162,12 @@
 fi
 
 echo $ac_n "checking for tm_zone in struct tm""... $ac_c" 1>&6
-echo "configure:5163: checking for tm_zone in struct tm" >&5
+echo "configure:5166: checking for tm_zone in struct tm" >&5
 if eval "test \"`echo '$''{'ac_cv_struct_tm_zone'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5168 "configure"
+#line 5171 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <$ac_cv_struct_tm>
@@ -5172,7 +5175,7 @@
 struct tm tm; tm.tm_zone;
 ; return 0; }
 EOF
-if { (eval echo configure:5176: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5179: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_struct_tm_zone=yes
 else
@@ -5192,12 +5195,12 @@
 
 else
   echo $ac_n "checking for tzname""... $ac_c" 1>&6
-echo "configure:5196: checking for tzname" >&5
+echo "configure:5199: checking for tzname" >&5
 if eval "test \"`echo '$''{'ac_cv_var_tzname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5201 "configure"
+#line 5204 "configure"
 #include "confdefs.h"
 #include <time.h>
 #ifndef tzname /* For SGI.  */
@@ -5207,7 +5210,7 @@
 atoi(*tzname);
 ; return 0; }
 EOF
-if { (eval echo configure:5211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_var_tzname=yes
 else
@@ -5232,12 +5235,12 @@
    for ac_func in gethostbyname_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5236: checking for $ac_func" >&5
+echo "configure:5239: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5241 "configure"
+#line 5244 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5260,7 +5263,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5264: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5267: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5287,7 +5290,7 @@
      # We look for the one that returns `int'.
      # Hopefully this check is robust enough.
      cat > conftest.$ac_ext <<EOF
-#line 5291 "configure"
+#line 5294 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 EOF
@@ -5307,7 +5310,7 @@
      *" -D_REENTRANT "*) ;;
      *)
 		echo $ac_n "checking whether gethostbyname_r declaration requires -D_REENTRANT""... $ac_c" 1>&6
-echo "configure:5311: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5
+echo "configure:5314: checking whether gethostbyname_r declaration requires -D_REENTRANT" >&5
 if eval "test \"`echo '$''{'libjava_cv_gethostbyname_r_needs_reentrant'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -5320,14 +5323,14 @@
 cross_compiling=$ac_cv_prog_cxx_cross
 
 	  cat > conftest.$ac_ext <<EOF
-#line 5324 "configure"
+#line 5327 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 gethostbyname_r("", 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:5331: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5334: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   libjava_cv_gethostbyname_r_needs_reentrant=no
 else
@@ -5337,14 +5340,14 @@
   		CPPFLAGS_SAVE="$CPPFLAGS"
 		CPPFLAGS="$CPPFLAGS -D_REENTRANT"
 		cat > conftest.$ac_ext <<EOF
-#line 5341 "configure"
+#line 5344 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 int main() {
 gethostbyname_r("", 0, 0);
 ; return 0; }
 EOF
-if { (eval echo configure:5348: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5351: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   libjava_cv_gethostbyname_r_needs_reentrant=yes
 else
@@ -5379,12 +5382,12 @@
      esac
 
      echo $ac_n "checking for struct hostent_data""... $ac_c" 1>&6
-echo "configure:5383: checking for struct hostent_data" >&5
+echo "configure:5386: checking for struct hostent_data" >&5
 if eval "test \"`echo '$''{'libjava_cv_struct_hostent_data'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   	cat > conftest.$ac_ext <<EOF
-#line 5388 "configure"
+#line 5391 "configure"
 #include "confdefs.h"
 
 #if GETHOSTBYNAME_R_NEEDS_REENTRANT && !defined(_REENTRANT)
@@ -5395,7 +5398,7 @@
 struct hostent_data data;
 ; return 0; }
 EOF
-if { (eval echo configure:5399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   libjava_cv_struct_hostent_data=yes
 else
@@ -5427,7 +5430,7 @@
    # to exist where expected.  (The root issue: AC_CHECK_FUNCS assumes C
    # linkage check is enough, yet C++ code requires proper prototypes.)
    cat > conftest.$ac_ext <<EOF
-#line 5431 "configure"
+#line 5434 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 EOF
@@ -5438,12 +5441,12 @@
    for ac_func in gethostbyaddr_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5442: checking for $ac_func" >&5
+echo "configure:5445: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5447 "configure"
+#line 5450 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5466,7 +5469,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5470: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5473: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5493,7 +5496,7 @@
      # We look for the one that returns `int'.
      # Hopefully this check is robust enough.
      cat > conftest.$ac_ext <<EOF
-#line 5497 "configure"
+#line 5500 "configure"
 #include "confdefs.h"
 #include <netdb.h>
 EOF
@@ -5520,12 +5523,12 @@
    for ac_func in gethostname
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5524: checking for $ac_func" >&5
+echo "configure:5527: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5529 "configure"
+#line 5532 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5548,7 +5551,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5552: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5555: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5572,7 +5575,7 @@
 EOF
 
      cat > conftest.$ac_ext <<EOF
-#line 5576 "configure"
+#line 5579 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -5596,12 +5599,12 @@
    for ac_func in usleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5600: checking for $ac_func" >&5
+echo "configure:5603: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5605 "configure"
+#line 5608 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5624,7 +5627,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5628: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5631: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5644,7 +5647,7 @@
 EOF
  
      cat > conftest.$ac_ext <<EOF
-#line 5648 "configure"
+#line 5651 "configure"
 #include "confdefs.h"
 #include <unistd.h>
 EOF
@@ -5675,12 +5678,12 @@
       for ac_func in pthread_mutexattr_settype pthread_mutexattr_setkind_np
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5679: checking for $ac_func" >&5
+echo "configure:5682: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5684 "configure"
+#line 5687 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5703,7 +5706,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5707: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5733,12 +5736,12 @@
       for ac_func in sched_yield
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5737: checking for $ac_func" >&5
+echo "configure:5740: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5742 "configure"
+#line 5745 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5761,7 +5764,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5765: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5783,7 +5786,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for sched_yield in -lrt""... $ac_c" 1>&6
-echo "configure:5787: checking for sched_yield in -lrt" >&5
+echo "configure:5790: checking for sched_yield in -lrt" >&5
 ac_lib_var=`echo rt'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5791,7 +5794,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lrt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5795 "configure"
+#line 5798 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5802,7 +5805,7 @@
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:5806: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5809: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5828,7 +5831,7 @@
   echo "$ac_t""no" 1>&6
 
 	  echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6
-echo "configure:5832: checking for sched_yield in -lposix4" >&5
+echo "configure:5835: checking for sched_yield in -lposix4" >&5
 ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -5836,7 +5839,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lposix4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 5840 "configure"
+#line 5843 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -5847,7 +5850,7 @@
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:5851: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -5883,7 +5886,7 @@
       # We can save a little space at runtime if the mutex has m_count
       # or __m_count.  This is a nice hack for Linux.
       cat > conftest.$ac_ext <<EOF
-#line 5887 "configure"
+#line 5890 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 int main() {
@@ -5892,7 +5895,7 @@
         
 ; return 0; }
 EOF
-if { (eval echo configure:5896: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5899: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define PTHREAD_MUTEX_HAVE_M_COUNT 1
@@ -5904,7 +5907,7 @@
   rm -rf conftest*
   
 	cat > conftest.$ac_ext <<EOF
-#line 5908 "configure"
+#line 5911 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 int main() {
@@ -5913,7 +5916,7 @@
 	  
 ; return 0; }
 EOF
-if { (eval echo configure:5917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:5920: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define PTHREAD_MUTEX_HAVE___M_COUNT 1
@@ -5933,12 +5936,12 @@
    for ac_func in gettimeofday time ftime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5937: checking for $ac_func" >&5
+echo "configure:5940: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 5942 "configure"
+#line 5945 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -5961,7 +5964,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:5965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:5968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -5992,12 +5995,12 @@
    for ac_func in memmove
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:5996: checking for $ac_func" >&5
+echo "configure:5999: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6001 "configure"
+#line 6004 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6020,7 +6023,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6024: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6050,12 +6053,12 @@
    for ac_func in memcpy
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6054: checking for $ac_func" >&5
+echo "configure:6057: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6059 "configure"
+#line 6062 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6078,7 +6081,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -6107,7 +6110,7 @@
    fi
 
    echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:6111: checking for dlopen in -ldl" >&5
+echo "configure:6114: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6115,7 +6118,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6119 "configure"
+#line 6122 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6126,7 +6129,7 @@
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:6130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6133: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6171,7 +6174,7 @@
    #--------------------------------------------------------------------
 
    echo $ac_n "checking for socket libraries""... $ac_c" 1>&6
-echo "configure:6175: checking for socket libraries" >&5
+echo "configure:6178: checking for socket libraries" >&5
 if eval "test \"`echo '$''{'gcj_cv_lib_sockets'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6179,12 +6182,12 @@
      gcj_checkBoth=0
      unset ac_cv_func_connect
      echo $ac_n "checking for connect""... $ac_c" 1>&6
-echo "configure:6183: checking for connect" >&5
+echo "configure:6186: checking for connect" >&5
 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6188 "configure"
+#line 6191 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char connect(); below.  */
@@ -6207,7 +6210,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6211: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_connect=yes"
 else
@@ -6230,7 +6233,7 @@
      if test "$gcj_checkSocket" = 1; then
 	 unset ac_cv_func_connect
 	 echo $ac_n "checking for main in -lsocket""... $ac_c" 1>&6
-echo "configure:6234: checking for main in -lsocket" >&5
+echo "configure:6237: checking for main in -lsocket" >&5
 ac_lib_var=`echo socket'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6238,14 +6241,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6242 "configure"
+#line 6245 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:6249: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6252: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6272,12 +6275,12 @@
 	 LIBS="$LIBS -lsocket -lnsl"
 	 unset ac_cv_func_accept
 	 echo $ac_n "checking for accept""... $ac_c" 1>&6
-echo "configure:6276: checking for accept" >&5
+echo "configure:6279: checking for accept" >&5
 if eval "test \"`echo '$''{'ac_cv_func_accept'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6281 "configure"
+#line 6284 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char accept(); below.  */
@@ -6300,7 +6303,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6304: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6307: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_accept=yes"
 else
@@ -6327,12 +6330,12 @@
      gcj_oldLibs=$LIBS
      LIBS="$LIBS $gcj_cv_lib_sockets"
      echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6
-echo "configure:6331: checking for gethostbyname" >&5
+echo "configure:6334: checking for gethostbyname" >&5
 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6336 "configure"
+#line 6339 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char gethostbyname(); below.  */
@@ -6355,7 +6358,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:6359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6362: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_gethostbyname=yes"
 else
@@ -6373,7 +6376,7 @@
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for main in -lnsl""... $ac_c" 1>&6
-echo "configure:6377: checking for main in -lnsl" >&5
+echo "configure:6380: checking for main in -lnsl" >&5
 ac_lib_var=`echo nsl'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6381,14 +6384,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6385 "configure"
+#line 6388 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:6392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6420,7 +6423,7 @@
 
    if test "$with_system_zlib" = yes; then
       echo $ac_n "checking for deflate in -lz""... $ac_c" 1>&6
-echo "configure:6424: checking for deflate in -lz" >&5
+echo "configure:6427: checking for deflate in -lz" >&5
 ac_lib_var=`echo z'_'deflate | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -6428,7 +6431,7 @@
   ac_save_LIBS="$LIBS"
 LIBS="-lz  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 6432 "configure"
+#line 6435 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -6439,7 +6442,7 @@
 deflate()
 ; return 0; }
 EOF
-if { (eval echo configure:6443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6446: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -6488,7 +6491,7 @@
   # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:6492: checking for $ac_word" >&5
+echo "configure:6495: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6536,7 +6539,7 @@
 
   min_gtk_version=2.0.0
   echo $ac_n "checking for GTK+ - version >= $min_gtk_version""... $ac_c" 1>&6
-echo "configure:6540: checking for GTK+ - version >= $min_gtk_version" >&5
+echo "configure:6543: checking for GTK+ - version >= $min_gtk_version" >&5
 
   if test x$PKG_CONFIG != xno ; then
     ## don't try to run the test against uninstalled libtool libs
@@ -6571,7 +6574,7 @@
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 6575 "configure"
+#line 6578 "configure"
 #include "confdefs.h"
 
 #include <gtk/gtk.h>
@@ -6646,7 +6649,7 @@
 }
 
 EOF
-if { (eval echo configure:6650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -6680,7 +6683,7 @@
           CFLAGS="$CFLAGS $GTK_CFLAGS"
           LIBS="$LIBS $GTK_LIBS"
           cat > conftest.$ac_ext <<EOF
-#line 6684 "configure"
+#line 6687 "configure"
 #include "confdefs.h"
 
 #include <gtk/gtk.h>
@@ -6690,7 +6693,7 @@
  return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); 
 ; return 0; }
 EOF
-if { (eval echo configure:6694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
    echo "*** The test program compiled, but did not run. This usually means"
           echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
@@ -6749,7 +6752,7 @@
   # Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:6753: checking for $ac_word" >&5
+echo "configure:6756: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6799,7 +6802,7 @@
 
   min_glib_version=2.0.0
   echo $ac_n "checking for GLIB - version >= $min_glib_version""... $ac_c" 1>&6
-echo "configure:6803: checking for GLIB - version >= $min_glib_version" >&5
+echo "configure:6806: checking for GLIB - version >= $min_glib_version" >&5
 
   if test x$PKG_CONFIG != xno ; then
     ## don't try to run the test against uninstalled libtool libs
@@ -6838,7 +6841,7 @@
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 6842 "configure"
+#line 6845 "configure"
 #include "confdefs.h"
 
 #include <glib.h>
@@ -6913,7 +6916,7 @@
 }
 
 EOF
-if { (eval echo configure:6917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6920: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -6947,7 +6950,7 @@
           CFLAGS="$CFLAGS $GLIB_CFLAGS"
           LIBS="$LIBS $GLIB_LIBS"
           cat > conftest.$ac_ext <<EOF
-#line 6951 "configure"
+#line 6954 "configure"
 #include "confdefs.h"
 
 #include <glib.h>
@@ -6957,7 +6960,7 @@
  return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); 
 ; return 0; }
 EOF
-if { (eval echo configure:6961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
    echo "*** The test program compiled, but did not run. This usually means"
           echo "*** that the run-time linker is not finding GLIB or finding the wrong"
@@ -7036,7 +7039,7 @@
   # Extract the first word of "libart2-config", so it can be a program name with args.
 set dummy libart2-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7040: checking for $ac_word" >&5
+echo "configure:7043: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_LIBART_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7073,7 +7076,7 @@
     # Extract the first word of "libart-config", so it can be a program name with args.
 set dummy libart-config; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7077: checking for $ac_word" >&5
+echo "configure:7080: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_LIBART_CONFIG'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7109,7 +7112,7 @@
   fi
   min_libart_version=2.1.0
   echo $ac_n "checking for LIBART - version >= $min_libart_version""... $ac_c" 1>&6
-echo "configure:7113: checking for LIBART - version >= $min_libart_version" >&5
+echo "configure:7116: checking for LIBART - version >= $min_libart_version" >&5
   no_libart=""
   if test "$LIBART_CONFIG" = "no" ; then
     no_libart=yes
@@ -7133,7 +7136,7 @@
   echo $ac_n "cross compiling; assumed OK... $ac_c"
 else
   cat > conftest.$ac_ext <<EOF
-#line 7137 "configure"
+#line 7140 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -7191,7 +7194,7 @@
 
 
 EOF
-if { (eval echo configure:7195: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7198: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -7225,7 +7228,7 @@
           CFLAGS="$CFLAGS $LIBART_CFLAGS"
           LIBS="$LIBS $LIBART_LIBS"
           cat > conftest.$ac_ext <<EOF
-#line 7229 "configure"
+#line 7232 "configure"
 #include "confdefs.h"
 
 #include <stdio.h>
@@ -7235,7 +7238,7 @@
  return 0; 
 ; return 0; }
 EOF
-if { (eval echo configure:7239: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
    echo "*** The test program compiled, but did not run. This usually means"
           echo "*** that the run-time linker is not finding LIBART or finding the wrong"
@@ -7274,7 +7277,7 @@
    # requires -ldl.
    if test "$GC" = boehm; then
       echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6
-echo "configure:7278: checking for main in -ldl" >&5
+echo "configure:7281: checking for main in -ldl" >&5
 ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -7282,14 +7285,14 @@
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 7286 "configure"
+#line 7289 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:7293: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7296: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -7410,7 +7413,7 @@
 # Extract the first word of "${ac_tool_prefix}gcj", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcj; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7414: checking for $ac_word" >&5
+echo "configure:7417: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCJ'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7442,7 +7445,7 @@
   # Extract the first word of "gcj", so it can be a program name with args.
 set dummy gcj; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:7446: checking for $ac_word" >&5
+echo "configure:7449: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_GCJ'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -7504,13 +7507,13 @@
 CPPFLAGS=$GCJ_SAVE_CPPFLAGS
 
 echo $ac_n "checking size of void *""... $ac_c" 1>&6
-echo "configure:7508: checking size of void *" >&5
+echo "configure:7511: checking size of void *" >&5
 if eval "test \"`echo '$''{'ac_cv_sizeof_void_p'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   for ac_size in 4 8 1 2 16 12  ; do # List sizes in rough order of prevalence.
   cat > conftest.$ac_ext <<EOF
-#line 7514 "configure"
+#line 7517 "configure"
 #include "confdefs.h"
 #include "confdefs.h"
 #include <sys/types.h>
@@ -7520,7 +7523,7 @@
 switch (0) case 0: case (sizeof (void *) == $ac_size):;
 ; return 0; }
 EOF
-if { (eval echo configure:7524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7527: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_sizeof_void_p=$ac_size
 else
@@ -7630,18 +7633,18 @@
 
 
 echo $ac_n "checking for g++ -ffloat-store bug""... $ac_c" 1>&6
-echo "configure:7634: checking for g++ -ffloat-store bug" >&5
+echo "configure:7637: checking for g++ -ffloat-store bug" >&5
 save_CFLAGS="$CFLAGS"
 CFLAGS="-x c++ -O2 -ffloat-store"
 cat > conftest.$ac_ext <<EOF
-#line 7638 "configure"
+#line 7641 "configure"
 #include "confdefs.h"
 #include <math.h>
 int main() {
 
 ; return 0; }
 EOF
-if { (eval echo configure:7645: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7648: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
 else
@@ -7661,17 +7664,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:7665: checking for $ac_hdr" >&5
+echo "configure:7668: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7670 "configure"
+#line 7673 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7675: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7678: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7701,17 +7704,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:7705: checking for $ac_hdr" >&5
+echo "configure:7708: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7710 "configure"
+#line 7713 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7715: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7718: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7741,17 +7744,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:7745: checking for $ac_hdr" >&5
+echo "configure:7748: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7750 "configure"
+#line 7753 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7755: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7758: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7787,12 +7790,12 @@
 done
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:7791: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:7794: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7796 "configure"
+#line 7799 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -7808,7 +7811,7 @@
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:7812: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7815: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -7830,12 +7833,12 @@
 
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:7834: checking for ANSI C header files" >&5
+echo "configure:7837: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7839 "configure"
+#line 7842 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -7843,7 +7846,7 @@
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:7847: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:7850: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -7860,7 +7863,7 @@
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 7864 "configure"
+#line 7867 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -7878,7 +7881,7 @@
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 7882 "configure"
+#line 7885 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -7899,7 +7902,7 @@
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 7903 "configure"
+#line 7906 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -7910,7 +7913,7 @@
 exit (0); }
 
 EOF
-if { (eval echo configure:7914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:7917: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -7934,12 +7937,12 @@
 fi
 
 echo $ac_n "checking for ssize_t""... $ac_c" 1>&6
-echo "configure:7938: checking for ssize_t" >&5
+echo "configure:7941: checking for ssize_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_ssize_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 7943 "configure"
+#line 7946 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -7968,9 +7971,9 @@
 
 
 echo $ac_n "checking for in_addr_t""... $ac_c" 1>&6
-echo "configure:7972: checking for in_addr_t" >&5
+echo "configure:7975: checking for in_addr_t" >&5
 cat > conftest.$ac_ext <<EOF
-#line 7974 "configure"
+#line 7977 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -7984,7 +7987,7 @@
 in_addr_t foo;
 ; return 0; }
 EOF
-if { (eval echo configure:7988: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:7991: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_IN_ADDR_T 1
@@ -8000,16 +8003,16 @@
 rm -f conftest*
 
 echo $ac_n "checking whether struct ip_mreq is in netinet/in.h""... $ac_c" 1>&6
-echo "configure:8004: checking whether struct ip_mreq is in netinet/in.h" >&5
+echo "configure:8007: checking whether struct ip_mreq is in netinet/in.h" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8006 "configure"
+#line 8009 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 int main() {
 struct ip_mreq mreq;
 ; return 0; }
 EOF
-if { (eval echo configure:8013: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8016: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_STRUCT_IP_MREQ 1
@@ -8025,16 +8028,16 @@
 rm -f conftest*
 
 echo $ac_n "checking whether struct ipv6_mreq is in netinet/in.h""... $ac_c" 1>&6
-echo "configure:8029: checking whether struct ipv6_mreq is in netinet/in.h" >&5
+echo "configure:8032: checking whether struct ipv6_mreq is in netinet/in.h" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8031 "configure"
+#line 8034 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 int main() {
 struct ipv6_mreq mreq6;
 ; return 0; }
 EOF
-if { (eval echo configure:8038: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8041: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_STRUCT_IPV6_MREQ 1
@@ -8050,16 +8053,16 @@
 rm -f conftest*
 
 echo $ac_n "checking whether struct sockaddr_in6 is in netinet/in.h""... $ac_c" 1>&6
-echo "configure:8054: checking whether struct sockaddr_in6 is in netinet/in.h" >&5
+echo "configure:8057: checking whether struct sockaddr_in6 is in netinet/in.h" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8056 "configure"
+#line 8059 "configure"
 #include "confdefs.h"
 #include <netinet/in.h>
 int main() {
 struct sockaddr_in6 addr6;
 ; return 0; }
 EOF
-if { (eval echo configure:8063: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8066: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_INET6 1
@@ -8075,9 +8078,9 @@
 rm -f conftest*
 
 echo $ac_n "checking for socklen_t in sys/socket.h""... $ac_c" 1>&6
-echo "configure:8079: checking for socklen_t in sys/socket.h" >&5
+echo "configure:8082: checking for socklen_t in sys/socket.h" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8081 "configure"
+#line 8084 "configure"
 #include "confdefs.h"
 #define _POSIX_PII_SOCKET
 #include <sys/types.h>
@@ -8086,7 +8089,7 @@
 socklen_t x = 5;
 ; return 0; }
 EOF
-if { (eval echo configure:8090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8093: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_SOCKLEN_T 1
@@ -8102,16 +8105,16 @@
 rm -f conftest*
 
 echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6
-echo "configure:8106: checking for tm_gmtoff in struct tm" >&5
+echo "configure:8109: checking for tm_gmtoff in struct tm" >&5
 cat > conftest.$ac_ext <<EOF
-#line 8108 "configure"
+#line 8111 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 struct tm tim; tim.tm_gmtoff = 0;
 ; return 0; }
 EOF
-if { (eval echo configure:8115: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8118: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define STRUCT_TM_HAS_GMTOFF 1
@@ -8124,16 +8127,16 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
    echo $ac_n "checking for global timezone variable""... $ac_c" 1>&6
-echo "configure:8128: checking for global timezone variable" >&5
+echo "configure:8131: checking for global timezone variable" >&5
                cat > conftest.$ac_ext <<EOF
-#line 8130 "configure"
+#line 8133 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 void i(){long z2 = 2*timezone;}
 ; return 0; }
 EOF
-if { (eval echo configure:8137: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_TIMEZONE 1
@@ -8146,16 +8149,16 @@
   rm -rf conftest*
   echo "$ac_t""no" 1>&6
        echo $ac_n "checking for global _timezone variable""... $ac_c" 1>&6
-echo "configure:8150: checking for global _timezone variable" >&5
+echo "configure:8153: checking for global _timezone variable" >&5
               cat > conftest.$ac_ext <<EOF
-#line 8152 "configure"
+#line 8155 "configure"
 #include "confdefs.h"
 #include <time.h>
 int main() {
 long z2 = _timezone;
 ; return 0; }
 EOF
-if { (eval echo configure:8159: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:8162: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   cat >> confdefs.h <<\EOF
 #define HAVE_UNDERSCORE_TIMEZONE 1
@@ -8177,19 +8180,19 @@
 # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
 # for constant arguments.  Useless!
 echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:8181: checking for working alloca.h" >&5
+echo "configure:8184: checking for working alloca.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8186 "configure"
+#line 8189 "configure"
 #include "confdefs.h"
 #include <alloca.h>
 int main() {
 char *p = alloca(2 * sizeof(int));
 ; return 0; }
 EOF
-if { (eval echo configure:8193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8196: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_header_alloca_h=yes
 else
@@ -8210,12 +8213,12 @@
 fi
 
 echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:8214: checking for alloca" >&5
+echo "configure:8217: checking for alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8219 "configure"
+#line 8222 "configure"
 #include "confdefs.h"
 
 #ifdef __GNUC__
@@ -8243,7 +8246,7 @@
 char *p = (char *) alloca(1);
 ; return 0; }
 EOF
-if { (eval echo configure:8247: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ac_cv_func_alloca_works=yes
 else
@@ -8275,12 +8278,12 @@
 
 
 echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:8279: checking whether alloca needs Cray hooks" >&5
+echo "configure:8282: checking whether alloca needs Cray hooks" >&5
 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8284 "configure"
+#line 8287 "configure"
 #include "confdefs.h"
 #if defined(CRAY) && ! defined(CRAY2)
 webecray
@@ -8305,12 +8308,12 @@
 if test $ac_cv_os_cray = yes; then
 for ac_func in _getb67 GETB67 getb67; do
   echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8309: checking for $ac_func" >&5
+echo "configure:8312: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8314 "configure"
+#line 8317 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8333,7 +8336,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8337: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8340: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8360,7 +8363,7 @@
 fi
 
 echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:8364: checking stack direction for C alloca" >&5
+echo "configure:8367: checking stack direction for C alloca" >&5
 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8368,7 +8371,7 @@
   ac_cv_c_stack_direction=0
 else
   cat > conftest.$ac_ext <<EOF
-#line 8372 "configure"
+#line 8375 "configure"
 #include "confdefs.h"
 find_stack_direction ()
 {
@@ -8387,7 +8390,7 @@
   exit (find_stack_direction() < 0);
 }
 EOF
-if { (eval echo configure:8391: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8394: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_c_stack_direction=1
 else
@@ -8412,17 +8415,17 @@
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:8416: checking for $ac_hdr" >&5
+echo "configure:8419: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8421 "configure"
+#line 8424 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:8426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:8429: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -8451,12 +8454,12 @@
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:8455: checking for $ac_func" >&5
+echo "configure:8458: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 8460 "configure"
+#line 8463 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -8479,7 +8482,7 @@
 
 ; return 0; }
 EOF
-if { (eval echo configure:8483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:8486: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -8504,7 +8507,7 @@
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:8508: checking for working mmap" >&5
+echo "configure:8511: checking for working mmap" >&5
 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -8512,7 +8515,7 @@
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 8516 "configure"
+#line 8519 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -8652,7 +8655,7 @@
 }
 
 EOF
-if { (eval echo configure:8656: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:8659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -8680,7 +8683,7 @@
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:8684: checking for $ac_word" >&5
+echo "configure:8687: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -9258,8 +9261,8 @@
 EOF
 
 cat >> $CONFIG_STATUS <<EOF
-ac_sources="include/$PLATFORMH java/io/natFile${FILE-${PLATFORM}}.cc java/io/natFileDescriptor${FILE-${PLATFORM}}.cc java/lang/${PLATFORM}Process.java java/lang/nat${PLATFORM}Process.cc java/net/natInetAddress${PLATFORMNET}.cc java/net/natNetworkInterface${PLATFORMNET}.cc java/net/natPlainSocketImpl${PLATFORMNET}.cc java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc include/$GCHDR include/$THREADH sysdep/$sysdeps_dir/locks.h $SIGNAL_HANDLER"
-ac_dests="include/platform.h java/io/natFile.cc java/io/natFileDescriptor.cc java/lang/ConcreteProcess.java java/lang/natConcreteProcess.cc java/net/natInetAddress.cc java/net/natNetworkInterface.cc java/net/natPlainSocketImpl.cc java/net/natPlainDatagramSocketImpl.cc include/java-gc.h include/java-threads.h sysdep/locks.h include/java-signal.h"
+ac_sources="include/$PLATFORMH java/io/natFile${FILE-${PLATFORM}}.cc java/io/natFileDescriptor${FILE-${PLATFORM}}.cc java/lang/${PLATFORM}Process.java java/lang/nat${PLATFORM}Process.cc java/net/natInetAddress${PLATFORMNET}.cc java/net/natNetworkInterface${PLATFORMNET}.cc gnu/java/net/natPlainSocketImpl${PLATFORMNET}.cc gnu/java/net/natPlainDatagramSocketImpl${PLATFORMNET}.cc include/$GCHDR include/$THREADH sysdep/$sysdeps_dir/locks.h $SIGNAL_HANDLER"
+ac_dests="include/platform.h java/io/natFile.cc java/io/natFileDescriptor.cc java/lang/ConcreteProcess.java java/lang/natConcreteProcess.cc java/net/natInetAddress.cc java/net/natNetworkInterface.cc gnu/java/net/natPlainSocketImpl.cc gnu/java/net/natPlainDatagramSocketImpl.cc include/java-gc.h include/java-threads.h sysdep/locks.h include/java-signal.h"
 EOF
 
 cat >> $CONFIG_STATUS <<\EOF
@@ -9453,7 +9456,7 @@
       fi
     fi
 
-    cd $ac_popdir
+    cd "$ac_popdir"
   done
 fi
 
Index: java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.26
diff -u -b -B -r1.26 DatagramSocket.java
--- java/net/DatagramSocket.java	11 Jun 2003 10:38:38 -0000	1.26
+++ java/net/DatagramSocket.java	6 Sep 2003 16:09:12 -0000
@@ -35,8 +35,10 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
+import gnu.java.net.PlainDatagramSocketImpl;
 import java.io.IOException;
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.IllegalBlockingModeException;
@@ -266,38 +268,30 @@
    */
   public InetAddress getLocalAddress()
   {
-    // FIXME: JCL p. 510 says this should call checkConnect.  But what
-    // string should be used as the hostname?  Maybe this is just a side
-    // effect of calling InetAddress.getLocalHost.
-    //
-    // And is getOption with SO_BINDADDR the right way to get the address?
-    // Doesn't seem to be since this method doesn't throw a SocketException
-    // and SO_BINADDR can throw one.
-    //
-    // Also see RETURNS section in JCL p. 510 about returning any local
-    // addr "if the current execution context is not allowed to connect to
-    // the network interface that is actually bound to this datagram socket."
-    // How is that done?  via InetAddress.getLocalHost?  But that throws
-    // an UnknownHostException and this method doesn't.
-    //
-    // if (s != null)
-    //   s.checkConnect("localhost", -1);
+    if (impl == null
+	|| closed)
+      return null;
+    
+    InetAddress result;
+    
     try
       {
-        return (InetAddress)impl.getOption(SocketOptions.SO_BINDADDR);
-      }
-    catch (SocketException ex)
-      {
-      }
+        result = (InetAddress) impl.getOption (SocketOptions.SO_BINDADDR);
 
-    try
+	SecurityManager s = System.getSecurityManager();
+	if (s != null)
+	  s.checkConnect (result.getHostName(), -1);
+      }
+    catch (SecurityException e)
       {
-        return InetAddress.getLocalHost();
+	result = InetAddress.ANY_IF;
       }
-    catch (UnknownHostException ex)
+    catch (SocketException e)
       {
-        return null;
+	result = InetAddress.ANY_IF;
       }
+
+    return result;
   }
 
   /**
Index: java/net/MulticastSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/MulticastSocket.java,v
retrieving revision 1.21
diff -u -b -B -r1.21 MulticastSocket.java
--- java/net/MulticastSocket.java	8 Jun 2003 09:25:54 -0000	1.21
+++ java/net/MulticastSocket.java	6 Sep 2003 16:09:12 -0000
@@ -36,8 +36,10 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
+import gnu.java.net.PlainDatagramSocketImpl;
 import java.io.IOException;
 import java.util.Enumeration;
 
Index: java/net/ServerSocket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/ServerSocket.java,v
retrieving revision 1.24
diff -u -b -B -r1.24 ServerSocket.java
--- java/net/ServerSocket.java	7 Aug 2003 06:30:16 -0000	1.24
+++ java/net/ServerSocket.java	6 Sep 2003 16:09:12 -0000
@@ -1,5 +1,5 @@
 /* ServerSocket.java -- Class for implementing server side sockets
-   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,8 +35,10 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
+import gnu.java.net.PlainSocketImpl;
 import java.io.IOException;
 import java.nio.channels.IllegalBlockingModeException;
 import java.nio.channels.ServerSocketChannel;
Index: java/net/Socket.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/Socket.java,v
retrieving revision 1.26
diff -u -b -B -r1.26 Socket.java
--- java/net/Socket.java	7 Aug 2003 06:30:16 -0000	1.26
+++ java/net/Socket.java	6 Sep 2003 16:09:12 -0000
@@ -1,5 +1,5 @@
 /* Socket.java -- Client socket implementation
-   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -35,8 +35,10 @@
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
+
 package java.net;
 
+import gnu.java.net.PlainSocketImpl;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.OutputStream;
Index: java/net/PlainDatagramSocketImpl.java
===================================================================
RCS file: java/net/PlainDatagramSocketImpl.java
diff -N java/net/PlainDatagramSocketImpl.java
--- java/net/PlainDatagramSocketImpl.java	25 Jun 2003 07:00:34 -0000	1.18
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,272 +0,0 @@
-/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
-   Copyright (C) 1998, 1999, 2001 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 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 java.net;
-
-import java.io.IOException;
-import gnu.classpath.Configuration;
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status:  Believed complete and correct.
- */
-
-/**
- * This is the default socket implementation for datagram sockets.
- * It makes native calls to C routines that implement BSD style
- * SOCK_DGRAM sockets in the AF_INET family.
- *
- * @author Aaron M. Renn <arenn@urbanophile.com>
- * @author Warren Levy <warrenl@cygnus.com>
- */
-class PlainDatagramSocketImpl extends DatagramSocketImpl
-{
-  // Static initializer to load native library
-  static
-  {
-    if (Configuration.INIT_LOAD_LIBRARY)
-      {
-        System.loadLibrary("javanet");
-      }
-  }
-  
-  // These fields are mirrored for use in native code to avoid cpp conflicts
-  // when the #defines in system header files are the same as the public fields.
-  static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
-                   _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
-                   _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
-                   _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
-                   _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
-                   _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
-                   _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
-                   _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
-                   _Jv_IP_TOS_ = SocketOptions.IP_TOS,
-                   _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
-                   _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
-                   _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
-                   _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
-                   _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
-
-  /**
-   * This is the actual underlying file descriptor
-   */
-  int fnum = -1;
-
-  // FIXME: Is this necessary?  Could it help w/ DatagramSocket.getLocalAddress?
-  // InetAddress address;
-  
-  // localAddress cache  
-  InetAddress localAddress;
-
-  // 'timeout' is set/read by setOption/getOption.
-  int timeout = 0;
-
-  /**
-   * Default do nothing constructor
-   */
-  public PlainDatagramSocketImpl()
-  {
-  }
-
-  /**
-   * Binds this socket to a particular port and interface
-   *
-   * @param port The port to bind to
-   * @param addr The address to bind to
-   *
-   * @exception SocketException If an error occurs
-   */
-  protected native void bind(int lport, InetAddress laddr)
-	throws SocketException;
-
-  protected native void connect (InetAddress i, int port)
-	throws SocketException;
-  
-  protected native void disconnect ();
-  
-  /**
-   * Creates a new datagram socket
-   *
-   * @exception SocketException If an error occurs
-   */
-  protected native void create() throws SocketException;
-  
-  protected native int peek(InetAddress i) throws IOException;
-  
-  protected native int peekData (DatagramPacket dp) throws IOException;
-
-  /**
-   * Sets the Time to Live value for the socket
-   *
-   * @param ttl The new TTL value
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native void setTimeToLive(int ttl) throws IOException;
-
-  /**
-   * Gets the Time to Live value for the socket
-   *
-   * @return The TTL value
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native int getTimeToLive() throws IOException;
-
-  /**
-   * Sends a packet of data to a remote host
-   *
-   * @param packet The packet to send
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native void send(DatagramPacket p) throws IOException;
-
-  /**
-   * Receives a UDP packet from the network
-   *
-   * @param packet The packet to fill in with the data received
-   *
-   * @exception IOException IOException If an error occurs
-   */
-  protected native void receive(DatagramPacket p) throws IOException;
-
-  /**
-   * 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
-   *
-   * @exception SocketException If an error occurs
-   */
-  public native void setOption(int optID, Object value) throws SocketException;
-
-  /**
-   * Retrieves the value of an option on the socket
-   *
-   * @param option_id The identifier of the option to retrieve
-   *
-   * @return The value of the option
-   *
-   * @exception SocketException If an error occurs
-   */
-  public native Object getOption(int optID) throws SocketException;
-  
-  private native void mcastGrp(InetAddress inetaddr, NetworkInterface netIf,
-		               boolean join) throws IOException;
-
-  /**
-   * Closes the socket
-   */
-  protected native void close();
-
-  /**
-   * Gets the Time to Live value for the socket
-   *
-   * @return The TTL value
-   *
-   * @exception IOException If an error occurs
-   *
-   * @deprecated 1.2
-   */
-  protected byte getTTL() throws IOException
-  {
-    return (byte) getTimeToLive();
-  }
-
-  /**
-   * Sets the Time to Live value for the socket
-   *
-   * @param ttl The new TTL value
-   *
-   * @exception IOException If an error occurs
-   *
-   * @deprecated 1.2
-   */
-  protected void setTTL(byte ttl) throws IOException
-  {
-    setTimeToLive(((int) ttl) & 0xFF);
-  }
-
-  /**
-   * Joins a multicast group
-   *
-   * @param addr The group to join
-   *
-   * @exception IOException If an error occurs
-   */
-  protected void join(InetAddress inetaddr) throws IOException
-  {
-    mcastGrp(inetaddr, null, true);
-  }
-
-  /**
-   * Leaves a multicast group
-   *
-   * @param addr The group to leave
-   *
-   * @exception IOException If an error occurs
-   */
-  protected void leave(InetAddress inetaddr) throws IOException
-  {
-    mcastGrp(inetaddr, null, false);
-  }
-
-  protected void joinGroup (SocketAddress mcastaddr, NetworkInterface netIf)
-	  throws IOException
-  {
-    mcastGrp(((InetSocketAddress)mcastaddr).getAddress(), netIf, true);
-  }
-
-  protected void leaveGroup (SocketAddress mcastaddr, NetworkInterface netIf)
-	  throws IOException
-  {
-    mcastGrp(((InetSocketAddress)mcastaddr).getAddress(), netIf, false);
-  }
-
-  protected void finalize() throws Throwable
-  {
-    synchronized (this)
-      {
-	if (fnum != -1)
-	  close();
-      }
-    super.finalize();
-  }
-}
Index: java/net/PlainSocketImpl.java
===================================================================
RCS file: java/net/PlainSocketImpl.java
diff -N java/net/PlainSocketImpl.java
--- java/net/PlainSocketImpl.java	21 Jun 2003 14:02:10 -0000	1.18
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,395 +0,0 @@
-/* PlainSocketImpl.java -- Default socket implementation
-   Copyright (C) 1998, 1999 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 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 java.net;
-
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import gnu.classpath.Configuration;
-
-/**
- * Written using on-line Java Platform 1.2 API Specification, as well
- * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
- * Status:  Believed complete and correct.
- */
-
-/**
- * Unless the application installs its own SocketImplFactory, this is the
- * default socket implemetation that will be used.  It simply uses a
- * combination of Java and native routines to implement standard BSD
- * style sockets of family AF_INET and types SOCK_STREAM and SOCK_DGRAM
- *
- * @author Per Bothner <bothner@cygnus.com>
- * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
- * @author Aaron M. Renn <arenn@urbanophile.com>
- */
-class PlainSocketImpl extends SocketImpl
-{
-  // Static initializer to load native library.
-  static
-    {
-      if (Configuration.INIT_LOAD_LIBRARY)
-        {
-          System.loadLibrary("javanet");
-        }
-    }
-  
-  // These fields are mirrored for use in native code to avoid cpp conflicts
-  // when the #defines in system header files are the same as the public fields.
-  static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
-                   _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
-                   _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
-                   _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
-                   _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
-                   _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
-                   _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
-                   _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
-                   _Jv_IP_TOS_ = SocketOptions.IP_TOS,
-                   _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
-                   _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
-                   _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
-                   _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
-                   _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
-
-  /**
-   * The OS file handle representing the socket.
-   * This is used for reads and writes to/from the socket and
-   * to close it.
-   *
-   * When the socket is closed this is reset to -1.
-   */
-  int fnum = -1;
-
-  // This value is set/read by setOption/getOption.
-  int timeout = 0;
-  
-  // localAddress cache
-  InetAddress localAddress;
-
-  /**
-   * A cached copy of the in stream for reading from the socket.
-   */
-  private InputStream in;
-
-  /**
-   * A cached copy of the out stream for writing to the socket.
-   */
-  private OutputStream out;
-
-  /**
-   * Default do nothing constructor
-   */
-  public PlainSocketImpl()
-  {
-  }
-  
-  protected void finalize() throws Throwable
-  {
-    synchronized (this)
-      {
-	if (fnum != -1)
-	  try
-	    {
-	      close();
-	    }
-	  catch (IOException ex)
-	    {
-	      // ignore
-	    }
-      }
-    super.finalize();
-  }
-
-  /**
-   * Sets the specified option on a socket to the passed in object.  For
-   * options that take an integer argument, the passed in object is an
-   * Integer.  The option_id parameter is one of the defined constants in
-   * this interface.
-   *
-   * @param option_id The identifier of the option
-   * @param val The value to set the option to
-   *
-   * @exception SocketException If an error occurs
-   */
-  public native void setOption(int optID, Object value) throws SocketException;
-
-  /**
-   * Returns the current setting of the specified option.  The Object returned
-   * will be an Integer for options that have integer values.  The option_id
-   * is one of the defined constants in this interface.
-   *
-   * @param option_id The option identifier
-   *
-   * @return The current value of the option
-   *
-   * @exception SocketException If an error occurs
-   */
-  public native Object getOption(int optID) throws SocketException;
-
-  public native void shutdownInput () throws IOException;
-
-  public native void shutdownOutput () throws IOException;
-
-  /**
-   * Creates a new socket that is not bound to any local address/port and
-   * is not connected to any remote address/port.  This will be created as
-   * a stream socket if the stream parameter is true, or a datagram socket
-   * if the stream parameter is false.
-   *
-   * @param stream true for a stream socket, false for a datagram socket
-   */
-  protected native void create (boolean stream)  throws IOException;
-
-  /**
-   * Connects to the remote hostname and port specified as arguments.
-   *
-   * @param hostname The remote hostname to connect to
-   * @param port The remote port to connect to
-   *
-   * @exception IOException If an error occurs
-   */
-  protected void connect (String host, int port) throws IOException
-  {
-    connect (new InetSocketAddress (InetAddress.getByName(host), port), 0);
-  }
-
-  /**
-   * Connects to the remote address and port specified as arguments.
-   *
-   * @param addr The remote address to connect to
-   * @param port The remote port to connect to
-   *
-   * @exception IOException If an error occurs
-   */
-  protected void connect (InetAddress host, int port) throws IOException
-  {
-    connect (new InetSocketAddress (host, port), 0);
-  }
-
-  protected native void connect (SocketAddress addr, int timeout)
-    throws IOException;
-
-  /**
-   * Binds to the specified port on the specified addr.  Note that this addr
-   * must represent a local IP address.  **** How bind to INADDR_ANY? ****
-   *
-   * @param addr The address to bind to
-   * @param port The port number to bind to
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native void bind (InetAddress host, int port) throws IOException;
-
-  /**
-   * Starts listening for connections on a socket. The queuelen parameter
-   * is how many pending connections will queue up waiting to be serviced
-   * before being accept'ed.  If the queue of pending requests exceeds this
-   * number, additional connections will be refused.
-   *
-   * @param queuelen The length of the pending connection queue
-   * 
-   * @exception IOException If an error occurs
-   */
-  protected native void listen (int backlog) throws IOException;
-
-  private native void accept (PlainSocketImpl s) throws IOException;
-
-  /**
-   * Accepts a new connection on this socket and returns in in the 
-   * passed in SocketImpl.
-   *
-   * @param impl The SocketImpl object to accept this connection.
-   */
-  protected void accept (SocketImpl s) throws IOException
-  {
-    accept((PlainSocketImpl) s);
-  }
-
-  /**
-   * Returns the number of bytes that the caller can read from this socket
-   * without blocking. 
-   *
-   * @return The number of readable bytes before blocking
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native int available() throws IOException;
-
-  /**
-   * Closes the socket.  This will cause any InputStream or OutputStream
-   * objects for this Socket to be closed as well.
-   * <p>
-   * Note that if the SO_LINGER option is set on this socket, then the
-   * operation could block.
-   *
-   * @exception IOException If an error occurs
-   */
-  protected native void close () throws IOException;
-
-  protected native void sendUrgentData(int data)
-    throws IOException;
-
-  native int read() throws IOException;
-
-  /**
-   * Internal method used by SocketInputStream for reading data from
-   * the connection.  Reads up to len bytes of data into the buffer
-   * buf starting at offset bytes into the buffer.
-   *
-   * @return The actual number of bytes read or -1 if end of stream.
-   *
-   * @exception IOException If an error occurs
-   */
-  native int read(byte[] buffer, int offset, int count)
-    throws IOException;
-
-  native void write(int c) throws IOException;
-
-  /**
-   * Internal method used by SocketOuputStream for writing data to
-   * the connection.  Writes up to len bytes of data from the buffer
-   * buf starting at offset bytes into the buffer.
-   *
-   * @exception IOException If an error occurs
-   */
-  native void write(byte[] buffer, int offset, int count)
-    throws IOException;
-
-  /**
-   * Returns an InputStream object for reading from this socket.  This will
-   * be an instance of SocketInputStream.
-   *
-   * @return An input stream attached to the socket.
-   *
-   * @exception IOException If an error occurs
-   */
-  protected synchronized InputStream getInputStream() throws IOException
-  {
-    if (in == null)
-      in = new SocketInputStream();
-    
-    return in;
-  }
-
-  /**
-   * Returns an OutputStream object for writing to this socket.  This will
-   * be an instance of SocketOutputStream.
-   *
-   * @return An output stream attached to the socket.
-   *
-   * @exception IOException If an error occurs
-   */
-  protected synchronized OutputStream getOutputStream() throws IOException
-  {
-    if (out == null)
-      out = new SocketOutputStream();
-    
-    return out;
-  }
-
-  /**
-   * A stream which reads from the socket implementation.
-   *
-   * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
-   */
-  class SocketInputStream
-    extends InputStream
-  {
-    SocketInputStream()
-    {
-    }
-    
-    public final void close() throws IOException
-    {
-      PlainSocketImpl.this.close();
-    }
-
-    public final int available() throws IOException
-    {
-      return PlainSocketImpl.this.available();
-    }
-
-    public final int read() throws IOException
-    {
-      return PlainSocketImpl.this.read();
-    }
-
-    public final int read(byte[] buffer, int offset, int length)
-      throws IOException
-    {
-      return PlainSocketImpl.this.read(buffer, offset, length);
-    }
-
-    public final int read(byte[] buffer)
-      throws IOException
-    {
-      return PlainSocketImpl.this.read(buffer, 0, buffer.length);
-    }
-  }
-
-  /** A stream which writes to the socket implementation.
-   *
-   * @author Nic Ferrier  <nferrier@tapsellferrier.co.uk>
-   */
-  class SocketOutputStream
-    extends OutputStream
-  {
-    public final void close() throws IOException
-    {
-      PlainSocketImpl.this.close();
-    }
-
-    public final void write(int c) throws IOException
-    {
-      PlainSocketImpl.this.write(c);
-    }
-
-    public final void write(byte[] buffer, int offset, int length)
-      throws IOException
-    {
-      PlainSocketImpl.this.write(buffer, offset, length);
-    }
-
-    public final void write(byte[] buffer)
-      throws IOException
-    {
-      PlainSocketImpl.this.write(buffer, 0, buffer.length);
-    }
-  }
-}
Index: java/net/SocketInputStream.java
===================================================================
RCS file: java/net/SocketInputStream.java
diff -N java/net/SocketInputStream.java
--- java/net/SocketInputStream.java	24 Jun 2003 11:07:23 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,204 +0,0 @@
-/* SocketInputStream.java -- An InputStream for Sockets
-   Copyright (C) 1998, 2000, 2002 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 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 java.net;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
-  * This class contains an implementation of <code>InputStream</code> for 
-  * sockets.  It in an internal only class used by <code>PlainSocketImpl</code>.
-  *
-  * @author Aaron M. Renn (arenn@urbanophile.com)
-  */
-class SocketInputStream extends InputStream
-{
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
-  * The PlainSocketImpl object this stream is associated with
-  */
-private PlainSocketImpl impl;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
-  * Builds an instance of this class from a PlainSocketImpl object
-  */
-protected
-SocketInputStream(PlainSocketImpl impl)
-{
-  this.impl = impl;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
-  * Returns the number of bytes available to be read before blocking
-  */
-public int
-available() throws IOException
-{
-  return(impl.available());
-}
-
-/*************************************************************************/
-
-/**
-  * Determines if "mark" functionality is supported on this stream.  For
-  * sockets, this is always false.  Note that the superclass default is
-  * false, but it is overridden out of safety concerns and/or paranoia.
-  */
-public boolean
-markSupported()
-{
-  return(false);
-}
-
-/*************************************************************************/
-
-/**
-  * Do nothing mark method since we don't support this functionality.  Again,
-  * overriding out of paranoia.
-  *
-  * @param readlimit In theory, the number of bytes we can read before the mark becomes invalid
-  */
-public void
-mark(int readlimit)
-{
-}
-
-/*************************************************************************/
-
-/**
-  * Since we don't support mark, this method always throws an exception
-  *
-  * @exception IOException Everytime since we don't support this functionality
-  */
-public void
-reset() throws IOException
-{
-  throw new IOException("Socket InputStreams do not support mark/reset");
-}
-
-/*************************************************************************/
-
-/**
-  * This method not only closes the stream, it closes the underlying socket
-  * (and thus any connection) and invalidates any other Input/Output streams
-  * for the underlying impl object
-  */
-public void
-close() throws IOException
-{
-  impl.close();
-} 
-
-/*************************************************************************/
-
-/**
-  * Reads the next byte of data and returns it as an int.  
-  *
-  * @return The byte read (as an int) or -1 if end of stream);
-  *
-  * @exception IOException If an error occurs.
-  */
-public int
-read() throws IOException
-{
-  byte buf[] = new byte[1];
-
-  int bytes_read = read(buf, 0, buf.length);
- 
-  if (bytes_read != -1)
-    return(buf[0] & 0xFF);
-  else
-    return(-1);
-}
-
-/*************************************************************************/
-
-/**
-  * Reads up to buf.length bytes of data into the caller supplied buffer.
-  *
-  * @return The actual number of bytes read or -1 if end of stream
-  *
-  * @exception IOException If an error occurs.
-  */
-public int
-read(byte[] buf) throws IOException
-{
-  return(read(buf, 0, buf.length));
-}
-
-/*************************************************************************/
-
-/**
-  * Reads up to len bytes of data into the caller supplied buffer starting
-  * at offset bytes from the start of the buffer
-  *
-  * @return The number of bytes actually read or -1 if end of stream
-  *
-  * @exception IOException If an error occurs.
-  */
-public int
-read(byte[] buf, int offset, int len) throws IOException
-{
-  int bytes_read = impl.read(buf, offset, len);
-  if (bytes_read == 0)
-    return(-1);
-
-  return(bytes_read);
-}
-
-} // class SocketInputStream
-
Index: java/net/SocketOutputStream.java
===================================================================
RCS file: java/net/SocketOutputStream.java
diff -N java/net/SocketOutputStream.java
--- java/net/SocketOutputStream.java	24 Jun 2003 11:07:23 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,165 +0,0 @@
-/* SocketOutputStream.java -- OutputStream for PlainSocketImpl
-   Copyright (C) 1998,2000 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., 59 Temple Place, Suite 330, Boston, MA
-02111-1307 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 java.net;
-
-import java.io.OutputStream;
-import java.io.IOException;
-
-/**
-  * This class is used internally by <code>PlainSocketImpl</code> to be the 
-  * <code>OutputStream</code> subclass returned by its 
-  * <code>getOutputStream method</code>.  It expects only to  be used in that 
-  * context.
-  *
-  * @author Aaron M. Renn (arenn@urbanophile.com)
-  */
-class SocketOutputStream extends OutputStream
-{
-
-/*************************************************************************/
-
-/*
- * Instance Variables
- */
-
-/**
-  * The PlainSocketImpl object this stream is associated with
-  */
-private PlainSocketImpl impl;
-
-/*************************************************************************/
-
-/*
- * Constructors
- */
-
-/**
-  * Build an instance of this class from a PlainSocketImpl object
-  */
-protected
-SocketOutputStream(PlainSocketImpl impl)
-{
-  this.impl = impl;
-}
-
-/*************************************************************************/
-
-/*
- * Instance Methods
- */
-
-/**
-  * This method closes the stream and the underlying socket connection.  This
-  * action also effectively closes any other InputStream or OutputStream
-  * object associated with the connection.
-  *
-  * @exception IOException If an error occurs
-  */
-public void
-close() throws IOException
-{
-  impl.close();
-}
-
-/*************************************************************************/
-
-/**
-  * Hmmm, we don't seem to have a flush() method in Socket impl, so just
-  * return for now, but this might need to be looked at later.
-  *
-  * @exception IOException Can't happen
-  */
-public void
-flush() throws IOException
-{
-  return;
-}
-
-/*************************************************************************/
-
-/**
-  * Writes a byte (passed in as an int) to the given output stream
-  * 
-  * @param b The byte to write
-  *
-  * @exception IOException If an error occurs
-  */
-public void
-write(int b) throws IOException
-{
-  byte buf[] = new byte[1];
-
-  Integer i = new Integer(b);
-  buf[0] = i.byteValue();
-
-  write(buf, 0, buf.length);
-}
-
-/*************************************************************************/
-
-/**
-  * Write an array of bytes to the output stream
-  *
-  * @param buf The array of bytes to write
-  *
-  * @exception IOException If an error occurs
-  */
-public void
-write(byte[] buf) throws IOException
-{
-  write(buf, 0, buf.length);
-}
-
-/*************************************************************************/
-
-/**
-  * Writes len number of bytes from the array buf to the stream starting
-  * at offset bytes into the buffer.
-  *
-  * @param buf The buffer
-  * @param offset Offset into the buffer to start writing from
-  * @param len The number of bytes to write
-  */
-public void
-write(byte[] buf, int offset, int len) throws IOException
-{
-  impl.write(buf, offset, len);
-}
-
-} // class SocketOutputStream
-
Index: java/net/natPlainDatagramSocketImplNoNet.cc
===================================================================
RCS file: java/net/natPlainDatagramSocketImplNoNet.cc
diff -N java/net/natPlainDatagramSocketImplNoNet.cc
--- java/net/natPlainDatagramSocketImplNoNet.cc	24 Mar 2003 13:40:44 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,119 +0,0 @@
-/* Copyright (C) 2003  Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-
-#include <java/io/IOException.h>
-#include <java/lang/Object.h>
-#include <java/net/BindException.h>
-#include <java/net/DatagramPacket.h>
-#include <java/net/InetAddress.h>
-#include <java/net/NetworkInterface.h>
-#include <java/net/PlainDatagramSocketImpl.h>
-#include <java/net/SocketException.h>
-
-void
-java::net::PlainDatagramSocketImpl::create ()
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("DatagramSocketImpl.create: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::bind (jint, java::net::InetAddress *)
-{
-  throw new BindException (
-    JvNewStringLatin1 ("DatagramSocketImpl.bind: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *, jint)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("DatagramSocketImpl.connect: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::disconnect ()
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("DatagramSocketImpl.disconnect: unimplemented"));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented"));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.peekData: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::close ()
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.close: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.send: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.receive: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setTimeToLive (jint)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.setTimeToLive: unimplemented"));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::getTimeToLive ()
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.getTimeToLive: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *,
-                                              java::net::NetworkInterface *,
-					      jboolean)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("DatagramSocketImpl.mcastGrp: unimplemented"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setOption (jint, java::lang::Object *)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("DatagramSocketImpl.setOption: unimplemented"));
-}
-
-java::lang::Object *
-java::net::PlainDatagramSocketImpl::getOption (jint)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("DatagramSocketImpl.getOption: unimplemented"));
-}
Index: java/net/natPlainDatagramSocketImplPosix.cc
===================================================================
RCS file: java/net/natPlainDatagramSocketImplPosix.cc
diff -N java/net/natPlainDatagramSocketImplPosix.cc
--- java/net/natPlainDatagramSocketImplPosix.cc	18 Mar 2003 06:01:16 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,750 +0,0 @@
-/* Copyright (C) 2003  Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#include <errno.h>
-#include <string.h>
-
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2 
-#include <bstring.h>
-#endif
-
-#include <gcj/cni.h>
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/SocketException.h>
-#include <java/net/PlainDatagramSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/NetworkInterface.h>
-#include <java/net/DatagramPacket.h>
-#include <java/net/PortUnreachableException.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Integer.h>
-
-union SockAddr
-{
-  struct sockaddr_in address;
-#ifdef HAVE_INET6
-  struct sockaddr_in6 address6;
-#endif
-};
-
-union McastReq
-{
-#if HAVE_STRUCT_IP_MREQ
-  struct ip_mreq mreq;
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
-  struct ipv6_mreq mreq6;
-#endif
-};
-
-union InAddr
-{
-  struct in_addr addr;
-#ifdef HAVE_INET6
-  struct in6_addr addr6;
-#endif
-};
-
-
-// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
-// NoRouteToHostException; also consider UnknownHostException, ConnectException.
-
-void
-java::net::PlainDatagramSocketImpl::create ()
-{
-  int sock = _Jv_socket (AF_INET, SOCK_DGRAM, 0);
-
-  if (sock < 0)
-    {
-      char* strerr = strerror (errno);
-      throw new java::net::SocketException (JvNewStringUTF (strerr));
-    }
-
-  _Jv_platform_close_on_exec (sock);
-
-  // We use fnum in place of fd here.  From leaving fd null we avoid
-  // the double close problem in FileDescriptor.finalize.
-  fnum = sock;
-}
-
-void
-java::net::PlainDatagramSocketImpl::bind (jint lport,
-					  java::net::InetAddress *host)
-{
-  union SockAddr u;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-
-      if (host != NULL)
-        memcpy (&u.address.sin_addr, bytes, len);
-      else
-        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
-
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (lport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (lport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (_Jv_bind (fnum, ptr, len) == 0)
-    {
-      socklen_t addrlen = sizeof(u);
-
-      if (lport != 0)
-        localPort = lport;
-      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
-        localPort = ntohs (u.address.sin_port);
-      else
-        goto error;
-
-      /* Allow broadcast by default. */
-      int broadcast = 1;
-      if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast, 
-                        sizeof (broadcast)) != 0)
-        goto error;
-
-      return;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::BindException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *, jint)
-{ 
-  throw new ::java::lang::InternalError (JvNewStringLatin1 (
-	    "PlainDatagramSocketImpl::connect: not implemented yet"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::disconnect ()
-{
-  throw new ::java::lang::InternalError (JvNewStringLatin1 (
-	    "PlainDatagramSocketImpl::disconnect: not implemented yet"));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  ssize_t retlen =
-    ::recvfrom (fnum, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
-      &addrlen);
-  if (retlen < 0)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  i->addr = raddr;
-  return rport;
- error:
-  char* strerr = strerror (errno);
-
-  if (errno == ECONNREFUSED)
-    throw new PortUnreachableException (JvNewStringUTF (strerr));
-
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
-  ssize_t retlen = 0;
-
-  // Do timeouts via select since SO_RCVTIMEO is not always available.
-  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
-    {
-      fd_set rset;
-      struct timeval tv;
-      FD_ZERO(&rset);
-      FD_SET(fnum, &rset);
-      tv.tv_sec = timeout / 1000;
-      tv.tv_usec = (timeout % 1000) * 1000;
-      int retval;
-      if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
-        goto error;
-      else if (retval == 0)
-        throw new java::io::InterruptedIOException ();
-    }
-
-  retlen =
-    ::recvfrom (fnum, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
-      &addrlen);
-  if (retlen < 0)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  p->setAddress (new InetAddress (raddr, NULL));
-  p->setPort (rport);
-  p->setLength ((jint) retlen);
-  return rport;
-
- error:
-  char* strerr = strerror (errno);
-
-  if (errno == ECONNREFUSED)
-    throw new PortUnreachableException (JvNewStringUTF (strerr));
-
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-// Close(shutdown) the socket.
-void
-java::net::PlainDatagramSocketImpl::close ()
-{
-  // Avoid races from asynchronous finalization.
-  JvSynchronize sync (this);
-
-  // The method isn't declared to throw anything, so we disregard
-  // the return value.
-  _Jv_close (fnum);
-  fnum = -1;
-  timeout = 0;
-}
-
-void
-java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  jint rport = p->getPort();
-  union SockAddr u;
-  jbyteArray haddress = p->getAddress()->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyte *dbytes = elements (p->getData());
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-      memcpy (&u.address.sin_addr, bytes, len);
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (rport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (rport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
-    return;
-
-  char* strerr = strerror (errno);
-
-  if (errno == ECONNREFUSED)
-    throw new PortUnreachableException (JvNewStringUTF (strerr));
-
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
-  ssize_t retlen = 0;
-
-  // Do timeouts via select since SO_RCVTIMEO is not always available.
-  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
-    {
-      fd_set rset;
-      struct timeval tv;
-      FD_ZERO(&rset);
-      FD_SET(fnum, &rset);
-      tv.tv_sec = timeout / 1000;
-      tv.tv_usec = (timeout % 1000) * 1000;
-      int retval;
-      if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
-        goto error;
-      else if (retval == 0)
-        throw new java::io::InterruptedIOException ();
-    }
-
-  retlen =
-    ::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
-      &addrlen);
-  if (retlen < 0)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  p->setAddress (new InetAddress (raddr, NULL));
-  p->setPort (rport);
-  p->setLength ((jint) retlen);
-  return;
-
- error:
-  char* strerr = strerror (errno);
-
-  if (errno == ECONNREFUSED)
-    throw new PortUnreachableException (JvNewStringUTF (strerr));
-
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
-{
-  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
-  char val = (char) ttl;
-  socklen_t val_len = sizeof(val);
-
-  if (::setsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
-    return;
-
-  char* strerr = strerror (errno);
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::getTimeToLive ()
-{
-  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
-  char val;
-  socklen_t val_len = sizeof(val);
-
-  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
-    return ((int) val) & 0xFF;
-
-  char* strerr = strerror (errno);
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *inetaddr,
-                                              java::net::NetworkInterface *,
-					      jboolean join)
-{
-  // FIXME: implement use of NetworkInterface
-
-  union McastReq u;
-  jbyteArray haddress = inetaddr->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  int level, opname;
-  const char *ptr;
-  if (0)
-    ;
-#if HAVE_STRUCT_IP_MREQ
-  else if (len == 4)
-    {
-      level = IPPROTO_IP;
-      opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
-      memcpy (&u.mreq.imr_multiaddr, bytes, len);
-      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
-      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
-      u.mreq.imr_interface.s_addr = htonl (INADDR_ANY); 
-      len = sizeof (struct ip_mreq);
-      ptr = (const char *) &u.mreq;
-    }
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
-  else if (len == 16)
-    {
-      level = IPPROTO_IPV6;
-
-      /* Prefer new RFC 2553 names.  */
-#ifndef IPV6_JOIN_GROUP
-#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
-#endif
-#ifndef IPV6_LEAVE_GROUP
-#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
-#endif
-
-      opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
-      memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
-      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
-      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
-      u.mreq6.ipv6mr_interface = 0;
-      len = sizeof (struct ipv6_mreq);
-      ptr = (const char *) &u.mreq6;
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::setsockopt (fnum, level, opname, ptr, len) == 0)
-    return;
-
-  char* strerr = strerror (errno);
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setOption (jint optID,
-					       java::lang::Object *value)
-{
-  int val;
-  socklen_t val_len = sizeof (val);
-
-  if (fnum < 0)
-    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
-
-  if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
-    {
-      java::lang::Boolean *boolobj = 
-        static_cast<java::lang::Boolean *> (value);
-      val = boolobj->booleanValue() ? 1 : 0;
-    }
-  else if (_Jv_IsInstanceOf (value, &java::lang::Integer::class$))
-    {
-      java::lang::Integer *intobj = 
-        static_cast<java::lang::Integer *> (value);          
-      val = (int) intobj->intValue();
-    }
-  // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
-
-  switch (optID) 
-    {
-      case _Jv_TCP_NODELAY_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
-        return;
-      case _Jv_SO_LINGER_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_LINGER not valid for UDP"));
-        return;
-      case _Jv_SO_KEEPALIVE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
-        return;
-
-      case _Jv_SO_BROADCAST_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-                          val_len) != 0)
-          goto error;
-	break;
-	
-      case _Jv_SO_OOBINLINE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
-        break;
-	
-      case _Jv_SO_SNDBUF_ :
-      case _Jv_SO_RCVBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
-	  goto error;    
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
-#endif 
-        return;
-      case _Jv_SO_REUSEADDR_ :
-#if defined(SO_REUSEADDR)
-	if (::setsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
-	    val_len) != 0)
-	  goto error;
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_REUSEADDR not supported"));
-#endif 
-	return;
-      case _Jv_SO_BINDADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_BINDADDR: read only option"));
-        return;
-      case _Jv_IP_MULTICAST_IF_ :
-	union InAddr u;
-        jbyteArray haddress;
-	jbyte *bytes;
-	int len;
-	int level, opname;
-	const char *ptr;
-
-	haddress = ((java::net::InetAddress *) value)->addr;
-	bytes = elements (haddress);
-	len = haddress->length;
-	if (len == 4)
-	  {
-	    level = IPPROTO_IP;
-	    opname = IP_MULTICAST_IF;
-	    memcpy (&u.addr, bytes, len);
-	    len = sizeof (struct in_addr);
-	    ptr = (const char *) &u.addr;
-	  }
-// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
-#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
-	else if (len == 16)
-	  {
-	    level = IPPROTO_IPV6;
-	    opname = IPV6_MULTICAST_IF;
-	    memcpy (&u.addr6, bytes, len);
-	    len = sizeof (struct in6_addr);
-	    ptr = (const char *) &u.addr6;
-	  }
-#endif
-	else
-	  throw
-	    new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-	if (::setsockopt (fnum, level, opname, ptr, len) != 0)
-	  goto error;
-        return;
-	
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
-        break;
-	
-      case _Jv_IP_MULTICAST_LOOP_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
-        break;
-	
-      case _Jv_IP_TOS_ :
-        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-	   val_len) != 0)
-	  goto error;    
-	return;
-	
-      case _Jv_SO_TIMEOUT_ :
-	timeout = val;
-        return;
-      default :
-        errno = ENOPROTOOPT;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::SocketException (JvNewStringUTF (strerr));
-}
-
-java::lang::Object *
-java::net::PlainDatagramSocketImpl::getOption (jint optID)
-{
-  int val;
-  socklen_t val_len = sizeof(val);
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-
-  switch (optID)
-    {
-      case _Jv_TCP_NODELAY_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
-        break;
-      case _Jv_SO_LINGER_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_LINGER not valid for UDP"));
-        break;    
-      case _Jv_SO_KEEPALIVE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
-        break;
-	
-      case _Jv_SO_BROADCAST_ :
-	if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-	    &val_len) != 0)
-	  goto error;
-	return new java::lang::Boolean (val != 0);
-	
-      case _Jv_SO_OOBINLINE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
-        break;
-      
-      case _Jv_SO_RCVBUF_ :
-      case _Jv_SO_SNDBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
-	  goto error;    
-        else
-	  return new java::lang::Integer (val);
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
-#endif    
-	break;
-      case _Jv_SO_BINDADDR_:
-	// cache the local address
-	if (localAddress == NULL)
-	  {	
-	    jbyteArray laddr;
-	    if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
-	      goto error;
-	    if (u.address.sin_family == AF_INET)
-	      {
-		laddr = JvNewByteArray (4);
-		memcpy (elements (laddr), &u.address.sin_addr, 4);
-	      }
-#ifdef HAVE_INET6
-            else if (u.address.sin_family == AF_INET6)
-	      {
-		laddr = JvNewByteArray (16);
-		memcpy (elements (laddr), &u.address6.sin6_addr, 16);
-	      }
-#endif
-	    else
-	      throw new java::net::SocketException (
-			      JvNewStringUTF ("invalid family"));
-	    localAddress = new java::net::InetAddress (laddr, NULL);
-	  }
-	return localAddress;  
-	break;
-      case _Jv_SO_REUSEADDR_ :
-#if defined(SO_REUSEADDR)
-	if (::getsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
-	    &val_len) != 0)
-	  goto error;
-	return new java::lang::Boolean (val != 0);
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_REUSEADDR not supported"));
-#endif 
-	break;
-      case _Jv_IP_MULTICAST_IF_ :
-#ifdef HAVE_INET_NTOA
-	struct in_addr inaddr;
-  	socklen_t inaddr_len;
-	char *bytes;
-
-  	inaddr_len = sizeof(inaddr);
-	if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
-	    &inaddr_len) != 0)
-	  goto error;
-
-	bytes = inet_ntoa (inaddr);
-
-	return java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
-#else
-	throw new java::net::SocketException (
-	  JvNewStringUTF ("IP_MULTICAST_IF: not available - no inet_ntoa()"));
-#endif
-	break;
-      case _Jv_SO_TIMEOUT_ :
-	return new java::lang::Integer (timeout);
-	break;
-	
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
-        break;
-	
-      case _Jv_IP_MULTICAST_LOOP_ :
-	if (::getsockopt (fnum, SOL_SOCKET, IP_MULTICAST_LOOP, (char *) &val,
-	    &val_len) != 0)
-	  goto error;
-	return new java::lang::Boolean (val != 0);
-	
-      case _Jv_IP_TOS_ :
-        if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-           &val_len) != 0)
-          goto error;
-        return new java::lang::Integer (val);
-	
-      default :
-	errno = ENOPROTOOPT;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::SocketException (JvNewStringUTF (strerr));
-}
Index: java/net/natPlainDatagramSocketImplWin32.cc
===================================================================
RCS file: java/net/natPlainDatagramSocketImplWin32.cc
diff -N java/net/natPlainDatagramSocketImplWin32.cc
--- java/net/natPlainDatagramSocketImplWin32.cc	29 Aug 2003 04:21:01 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,704 +0,0 @@
-/* Copyright (C) 2003  Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-#include <string.h>
-
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
-#include <bstring.h>
-#endif
-
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/SocketException.h>
-#include <java/net/PlainDatagramSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/NetworkInterface.h>
-#include <java/net/DatagramPacket.h>
-#include <java/net/PortUnreachableException.h>
-#include <java/net/SocketTimeoutException.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Integer.h>
-
-union SockAddr
-{
-  struct sockaddr_in address;
-#ifdef HAVE_INET6
-  struct sockaddr_in6 address6;
-#endif
-};
-
-union McastReq
-{
-#if HAVE_STRUCT_IP_MREQ
-  struct ip_mreq mreq;
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
-  struct ipv6_mreq mreq6;
-#endif
-};
-
-union InAddr
-{
-  struct in_addr addr;
-#ifdef HAVE_INET6
-  struct in6_addr addr6;
-#endif
-};
-
-// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
-// NoRouteToHostException; also consider UnknownHostException, ConnectException.
-
-void
-java::net::PlainDatagramSocketImpl::create ()
-{
-  SOCKET sock = ::socket (AF_INET, SOCK_DGRAM, 0);
-
-  if (sock == INVALID_SOCKET)
-    {
-      _Jv_ThrowSocketException ();
-    }
-
-  _Jv_platform_close_on_exec (sock);
-
-  // We use fnum in place of fd here.  From leaving fd null we avoid
-  // the double close problem in FileDescriptor.finalize.
-  fnum = (int) sock;
-}
-
-void
-java::net::PlainDatagramSocketImpl::bind (jint lport,
-            java::net::InetAddress *host)
-{
-  union SockAddr u;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-
-      if (host != NULL)
-        memcpy (&u.address.sin_addr, bytes, len);
-      else
-        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
-
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (lport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (lport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::bind (fnum, ptr, len) == 0)
-    {
-      socklen_t addrlen = sizeof(u);
-
-      if (lport != 0)
-        localPort = lport;
-      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
-        localPort = ntohs (u.address.sin_port);
-      else
-        goto error;
-
-      /* Allow broadcast by default. */
-      int broadcast = 1;
-      if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast,
-                        sizeof (broadcast)) != 0)
-        goto error;
-
-      return;
-    }
-
-error:
-  DWORD dwErrorCode = WSAGetLastError ();
-  throw new java::net::BindException (_Jv_WinStrError (dwErrorCode));
-}
-
-void
-java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *, jint)
-{
-  throw new ::java::lang::InternalError (JvNewStringLatin1 (
-      "PlainDatagramSocketImpl::connect: not implemented yet"));
-}
-
-void
-java::net::PlainDatagramSocketImpl::disconnect ()
-{
-  throw new ::java::lang::InternalError (JvNewStringLatin1 (
-      "PlainDatagramSocketImpl::disconnect: not implemented yet"));
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peek (java::net::InetAddress *i)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  ssize_t retlen =
-    ::recvfrom (fnum, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
-      &addrlen);
-  if (retlen < 0)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  i->addr = raddr;
-  return rport;
-error:
-  DWORD dwErrorCode = WSAGetLastError ();
-  if (dwErrorCode == WSAECONNRESET)
-    throw new PortUnreachableException (_Jv_WinStrError (dwErrorCode));
-
-  _Jv_ThrowIOException ();
-  return -1;
-    // we should never get here
-}
-
-jint
-java::net::PlainDatagramSocketImpl::peekData(java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
-  ssize_t retlen = 0;
-
-  if (timeout > 0)
-    {
-      int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
-        (char*)&timeout, sizeof(timeout));
-      if (nRet != NO_ERROR)
-        goto error;
-    }
-
-  retlen =
-    ::recvfrom (fnum, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
-      &addrlen);
-  if (retlen == SOCKET_ERROR)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  p->setAddress (new InetAddress (raddr, NULL));
-  p->setPort (rport);
-  p->setLength ((jint) retlen);
-  return rport;
-
-error:
-  DWORD dwErrorCode = WSAGetLastError ();
-  if (dwErrorCode == WSAECONNRESET)
-    throw new PortUnreachableException (_Jv_WinStrError (dwErrorCode));
-  else if (dwErrorCode == WSAETIMEDOUT)
-    throw new java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
-  else
-    _Jv_ThrowIOException ();
-
-  return -1;
-    // we should never get here
-}
-
-// Close(shutdown) the socket.
-void
-java::net::PlainDatagramSocketImpl::close ()
-{
-  // Avoid races from asynchronous finalization.
-  JvSynchronize sync (this);
-
-  // The method isn't declared to throw anything, so we disregard
-  // the return value.
-  ::closesocket (fnum);
-  fnum = -1;
-  timeout = 0;
-}
-
-void
-java::net::PlainDatagramSocketImpl::send (java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  jint rport = p->getPort();
-  union SockAddr u;
-  jbyteArray haddress = p->getAddress()->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyte *dbytes = elements (p->getData());
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-      memcpy (&u.address.sin_addr, bytes, len);
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (rport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (rport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
-    return;
-
-  DWORD dwErrorCode = WSAGetLastError ();
-  if (dwErrorCode == WSAECONNRESET)
-    throw new PortUnreachableException (_Jv_WinStrError (dwErrorCode));
-
-  _Jv_ThrowIOException ();
-}
-
-void
-java::net::PlainDatagramSocketImpl::receive (java::net::DatagramPacket *p)
-{
-  // FIXME: Deal with Multicast and if the socket is connected.
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyte *dbytes = elements (p->getData());
-  ssize_t retlen = 0;
-
-  if (timeout > 0)
-    {
-      // This implementation doesn't allow specifying an infinite
-      // timeout after specifying a finite one, but Sun's JDK 1.4.1
-      // didn't seem to allow this either....
-      int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
-        (char*)&timeout, sizeof(timeout));
-      if (nRet != NO_ERROR)
-        goto error;
-    }
-
-  retlen =
-    ::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
-      &addrlen);
-  if (retlen < 0)
-    goto error;
-  // FIXME: Deal with Multicast addressing and if the socket is connected.
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  p->setAddress (new InetAddress (raddr, NULL));
-  p->setPort (rport);
-  p->setLength ((jint) retlen);
-  return;
-
- error:
-  DWORD dwErrorCode = WSAGetLastError();
-  if (dwErrorCode == WSAECONNRESET)
-    throw new PortUnreachableException (_Jv_WinStrError (dwErrorCode));
-  else if (dwErrorCode == WSAETIMEDOUT)
-    throw new java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
-  else
-    throw new java::io::IOException (_Jv_WinStrError (dwErrorCode));
-}
-
-void
-java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
-{
-  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
-  char val = (char) ttl;
-  socklen_t val_len = sizeof(val);
-
-  if (::setsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
-    return;
-
-  _Jv_ThrowIOException ();
-}
-
-jint
-java::net::PlainDatagramSocketImpl::getTimeToLive ()
-{
-  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
-  char val;
-  socklen_t val_len = sizeof(val);
-
-  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
-    return ((int) val) & 0xFF;
-
-  _Jv_ThrowIOException ();
-
-  return -1;
-    // we should never get here
-}
-
-void
-java::net::PlainDatagramSocketImpl::mcastGrp (java::net::InetAddress *inetaddr,
-                                              java::net::NetworkInterface *,
-                jboolean)
-{
-  // FIXME: implement use of NetworkInterface
-  jbyteArray haddress = inetaddr->addr;
-  int len = haddress->length;
-  int level, opname;
-  const char *ptr;
-  if (0)
-    ;
-#if HAVE_STRUCT_IP_MREQ
-  else if (len == 4)
-    {
-      level = IPPROTO_IP;
-      opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
-      memcpy (&u.mreq.imr_multiaddr, bytes, len);
-      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
-      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
-      u.mreq.imr_interface.s_addr = htonl (INADDR_ANY);
-      len = sizeof (struct ip_mreq);
-      ptr = (const char *) &u.mreq;
-    }
-#endif
-#if HAVE_STRUCT_IPV6_MREQ
-  else if (len == 16)
-    {
-      level = IPPROTO_IPV6;
-
-      /* Prefer new RFC 2553 names.  */
-#ifndef IPV6_JOIN_GROUP
-#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
-#endif
-#ifndef IPV6_LEAVE_GROUP
-#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
-#endif
-
-      opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
-      memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
-      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
-      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
-      u.mreq6.ipv6mr_interface = 0;
-      len = sizeof (struct ipv6_mreq);
-      ptr = (const char *) &u.mreq6;
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::setsockopt (fnum, level, opname, ptr, len) == 0)
-    return;
-
-  _Jv_ThrowIOException ();
-}
-
-void
-java::net::PlainDatagramSocketImpl::setOption (jint optID,
-                 java::lang::Object *value)
-{
-  int val;
-  socklen_t val_len = sizeof (val);
-
-  if (fnum < 0)
-    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
-
-  if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
-    {
-      java::lang::Boolean *boolobj =
-        static_cast<java::lang::Boolean *> (value);
-      val = boolobj->booleanValue() ? 1 : 0;
-    }
-  else if (_Jv_IsInstanceOf (value, &java::lang::Integer::class$))
-    {
-      java::lang::Integer *intobj =
-        static_cast<java::lang::Integer *> (value);
-      val = (int) intobj->intValue();
-    }
-  // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
-
-  switch (optID)
-    {
-      case _Jv_TCP_NODELAY_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
-        return;
-      case _Jv_SO_LINGER_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_LINGER not valid for UDP"));
-        return;
-      case _Jv_SO_KEEPALIVE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
-        return;
-
-      case _Jv_SO_BROADCAST_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-                          val_len) != 0)
-          goto error;
-  break;
-
-      case _Jv_SO_OOBINLINE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
-        break;
-
-      case _Jv_SO_SNDBUF_ :
-      case _Jv_SO_RCVBUF_ :
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
-    goto error;
-        return;
-      case _Jv_SO_REUSEADDR_ :
-  if (::setsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
-      val_len) != 0)
-    goto error;
-  return;
-      case _Jv_SO_BINDADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_BINDADDR: read only option"));
-        return;
-      case _Jv_IP_MULTICAST_IF_ :
-  union InAddr u;
-        jbyteArray haddress;
-  jbyte *bytes;
-  int len;
-  int level, opname;
-  const char *ptr;
-
-  haddress = ((java::net::InetAddress *) value)->addr;
-  bytes = elements (haddress);
-  len = haddress->length;
-  if (len == 4)
-    {
-      level = IPPROTO_IP;
-      opname = IP_MULTICAST_IF;
-      memcpy (&u.addr, bytes, len);
-      len = sizeof (struct in_addr);
-      ptr = (const char *) &u.addr;
-    }
-// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
-#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
-  else if (len == 16)
-    {
-      level = IPPROTO_IPV6;
-      opname = IPV6_MULTICAST_IF;
-      memcpy (&u.addr6, bytes, len);
-      len = sizeof (struct in6_addr);
-      ptr = (const char *) &u.addr6;
-    }
-#endif
-  else
-    throw
-      new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (::setsockopt (fnum, level, opname, ptr, len) != 0)
-    goto error;
-        return;
-
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
-        break;
-
-      case _Jv_IP_MULTICAST_LOOP_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
-        break;
-
-      case _Jv_IP_TOS_ :
-        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-     val_len) != 0)
-    goto error;
-  return;
-
-      case _Jv_SO_TIMEOUT_ :
-  timeout = val;
-        return;
-      default :
-        WSASetLastError (WSAENOPROTOOPT);
-    }
-
- error:
-  _Jv_ThrowSocketException ();
-}
-
-java::lang::Object *
-java::net::PlainDatagramSocketImpl::getOption (jint optID)
-{
-  int val;
-  socklen_t val_len = sizeof(val);
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-
-  switch (optID)
-    {
-      case _Jv_TCP_NODELAY_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
-        break;
-      case _Jv_SO_LINGER_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_LINGER not valid for UDP"));
-        break;
-      case _Jv_SO_KEEPALIVE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
-        break;
-
-      case _Jv_SO_BROADCAST_ :
-  if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-      &val_len) != 0)
-    goto error;
-  return new java::lang::Boolean (val != 0);
-
-      case _Jv_SO_OOBINLINE_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
-        break;
-
-      case _Jv_SO_RCVBUF_ :
-      case _Jv_SO_SNDBUF_ :
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
-    goto error;
-        else
-    return new java::lang::Integer (val);
-  break;
-      case _Jv_SO_BINDADDR_:
-  // cache the local address
-  if (localAddress == NULL)
-    {
-      jbyteArray laddr;
-      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
-        goto error;
-      if (u.address.sin_family == AF_INET)
-        {
-    laddr = JvNewByteArray (4);
-    memcpy (elements (laddr), &u.address.sin_addr, 4);
-        }
-#ifdef HAVE_INET6
-            else if (u.address.sin_family == AF_INET6)
-        {
-    laddr = JvNewByteArray (16);
-    memcpy (elements (laddr), &u.address6.sin6_addr, 16);
-        }
-#endif
-      else
-        throw new java::net::SocketException (
-            JvNewStringUTF ("invalid family"));
-      localAddress = new java::net::InetAddress (laddr, NULL);
-    }
-  return localAddress;
-  break;
-      case _Jv_SO_REUSEADDR_ :
-  if (::getsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
-      &val_len) != 0)
-    goto error;
-  return new java::lang::Boolean (val != 0);
-  break;
-      case _Jv_IP_MULTICAST_IF_ :
-  struct in_addr inaddr;
-    socklen_t inaddr_len;
-  char *bytes;
-
-    inaddr_len = sizeof(inaddr);
-  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
-      &inaddr_len) != 0)
-    goto error;
-
-  bytes = inet_ntoa (inaddr);
-
-  return java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
-  break;
-      case _Jv_SO_TIMEOUT_ :
-  return new java::lang::Integer (timeout);
-  break;
-
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
-        break;
-
-      case _Jv_IP_MULTICAST_LOOP_ :
-  if (::getsockopt (fnum, SOL_SOCKET, IP_MULTICAST_LOOP, (char *) &val,
-      &val_len) != 0)
-    goto error;
-  return new java::lang::Boolean (val != 0);
-
-      case _Jv_IP_TOS_ :
-        if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-           &val_len) != 0)
-          goto error;
-        return new java::lang::Integer (val);
-
-      default :
-        WSASetLastError (WSAENOPROTOOPT);
-    }
-
-error:
-  _Jv_ThrowSocketException ();
-  return 0;
-    // we should never get here
-}
Index: java/net/natPlainSocketImplNoNet.cc
===================================================================
RCS file: java/net/natPlainSocketImplNoNet.cc
diff -N java/net/natPlainSocketImplNoNet.cc
--- java/net/natPlainSocketImplNoNet.cc	24 Mar 2003 13:40:44 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,128 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-
-#include <java/io/IOException.h>
-#include <java/net/BindException.h>
-#include <java/net/ConnectException.h>
-#include <java/net/PlainSocketImpl.h>
-#include <java/net/SocketException.h>
-
-void
-java::net::PlainSocketImpl::create (jboolean)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("SocketImpl.create: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::bind (java::net::InetAddress *, jint)
-{
-  throw new BindException (
-    JvNewStringLatin1 ("SocketImpl.bind: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::connect (java::net::SocketAddress *, jint)
-{
-  throw new ConnectException (
-    JvNewStringLatin1 ("SocketImpl.connect: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::listen (jint)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("SocketImpl.listen: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *)
-{
-  throw new java::io::IOException (
-    JvNewStringLatin1 ("SocketImpl.accept: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::setOption (jint, java::lang::Object *)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.setOption: unimplemented"));
-}
-
-java::lang::Object *
-java::net::PlainSocketImpl::getOption (jint)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.getOption: unimplemented"));
-}
-
-jint
-java::net::PlainSocketImpl::read(void)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
-}
-
-jint
-java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::write(jint b)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::sendUrgentData(jint data)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.sendUrgentData: unimplemented"));
-}
-
-jint
-java::net::PlainSocketImpl::available(void)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.available: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::close(void)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.close: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::shutdownInput (void)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.shutdownInput: unimplemented"));
-}
-
-void
-java::net::PlainSocketImpl::shutdownOutput (void)
-{
-  throw new SocketException (
-    JvNewStringLatin1 ("SocketImpl.shutdownOutput: unimplemented"));
-}
Index: java/net/natPlainSocketImplPosix.cc
===================================================================
RCS file: java/net/natPlainSocketImplPosix.cc
diff -N java/net/natPlainSocketImplPosix.cc
--- java/net/natPlainSocketImplPosix.cc	7 Aug 2003 01:13:46 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,857 +0,0 @@
-/* Copyright (C) 2003  Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-
-#ifdef HAVE_SYS_IOCTL_H
-#define BSD_COMP /* Get FIONREAD on Solaris2. */
-#include <sys/ioctl.h>
-#endif
-
-// Pick up FIONREAD on Solaris 2.5.
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
-#endif
-
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <errno.h>
-#include <string.h>
-
-#if HAVE_BSTRING_H
-// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2 
-#include <bstring.h>
-#endif
-
-#include <gcj/cni.h>
-#include <gcj/javaprims.h>
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/ConnectException.h>
-#include <java/net/PlainSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/InetSocketAddress.h>
-#include <java/net/SocketException.h>
-#include <java/net/SocketTimeoutException.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Class.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Thread.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/IllegalArgumentException.h>
-
-union SockAddr
-{
-  struct sockaddr_in address;
-#ifdef HAVE_INET6
-  struct sockaddr_in6 address6;
-#endif
-};
-
-void
-java::net::PlainSocketImpl::create (jboolean stream)
-{
-  int sock = _Jv_socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
-
-  if (sock < 0)
-    {
-      char* strerr = strerror (errno);
-      throw new java::io::IOException (JvNewStringUTF (strerr));
-    }
-
-  _Jv_platform_close_on_exec (sock);
-
-  // We use fnum in place of fd here.  From leaving fd null we avoid
-  // the double close problem in FileDescriptor.finalize.
-  fnum = sock;
-}
-
-void
-java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport)
-{
-  union SockAddr u;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  int i = 1;
-
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-
-      if (host != NULL)
-        memcpy (&u.address.sin_addr, bytes, len);
-      else
-        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
-
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (lport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (lport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
-  ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
-  
-  if (_Jv_bind (fnum, ptr, len) == 0)
-    {
-      address = host;
-      socklen_t addrlen = sizeof(u);
-
-      if (lport != 0)
-        localport = lport;
-      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
-        localport = ntohs (u.address.sin_port);
-      else
-        goto error;
-
-      return;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::BindException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainSocketImpl::connect (java::net::SocketAddress *addr,
-                                     jint timeout)
-{
-  java::net::InetSocketAddress *tmp = (java::net::InetSocketAddress*) addr;
-  java::net::InetAddress *host = tmp->getAddress();
-  jint rport = tmp->getPort();
-	
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-      memcpy (&u.address.sin_addr, bytes, len);
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (rport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (rport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (timeout > 0)
-    {
-      int flags = ::fcntl (fnum, F_GETFL);
-      ::fcntl (fnum, F_SETFL, flags | O_NONBLOCK);
-      
-      if ((_Jv_connect (fnum, ptr, len) != 0) && (errno != EINPROGRESS))
-        goto error;
-
-      fd_set fset;
-      struct timeval tv;
-      FD_ZERO(&fset);
-      FD_SET(fnum, &fset);
-      tv.tv_sec = timeout / 1000;
-      tv.tv_usec = (timeout % 1000) * 1000;
-      int retval;
-      
-      if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
-        goto error;
-      else if (retval == 0)
-        throw new java::net::SocketTimeoutException
-          (JvNewStringUTF ("Connect timed out"));
-       // Set the socket back into a blocking state.
-       ::fcntl (fnum, F_SETFL, flags);
-    }
-  else
-    {
-      if (_Jv_connect (fnum, ptr, len) != 0)
-        goto error;
-    }
-
-  address = host;
-  port = rport;
-
-  // A bind may not have been done on this socket; if so, set localport now.
-  if (localport == 0)
-    {
-      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
-        localport = ntohs (u.address.sin_port);
-      else
-        goto error;
-    }
-
-  return;  
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::ConnectException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainSocketImpl::listen (jint backlog)
-{
-  if (::listen (fnum, backlog) != 0)
-    {
-      char* strerr = strerror (errno);
-      throw new java::io::IOException (JvNewStringUTF (strerr));
-    }
-}
-
-void
-java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
-{
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  int new_socket = 0; 
-
-  // Do timeouts via select since SO_RCVTIMEO is not always available.
-  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
-    {
-      fd_set fset;
-      struct timeval tv;
-      FD_ZERO(&fset);
-      FD_SET(fnum, &fset);
-      tv.tv_sec = timeout / 1000;
-      tv.tv_usec = (timeout % 1000) * 1000;
-      int retval;
-      if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
-        goto error;
-      else if (retval == 0)
-        throw new java::net::SocketTimeoutException (
-	                                  JvNewStringUTF("Accept timed out"));
-    }
-
-  new_socket = _Jv_accept (fnum, (sockaddr*) &u, &addrlen);
-
-  if (new_socket < 0)
-    goto error;
-
-  _Jv_platform_close_on_exec (new_socket);
-
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  s->fnum = new_socket;
-  s->localport = localport;
-  s->address = new InetAddress (raddr, NULL);
-  s->port = rport;
-  return;
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::io::IOException (JvNewStringUTF (strerr));
-}
-
-// Close(shutdown) the socket.
-void
-java::net::PlainSocketImpl::close()
-{
-  // Avoid races from asynchronous finalization.
-  JvSynchronize sync (this);
-
-  // should we use shutdown here? how would that effect so_linger?
-  int res = _Jv_close (fnum);
-
-  if (res == -1)
-    {
-      // These three errors are not errors according to tests performed
-      // on the reference implementation.
-      if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
-        throw new java::io::IOException  (JvNewStringUTF (strerror (errno)));
-    }
-  // Safe place to reset the file pointer.
-  fnum = -1;
-  timeout = 0;
-}
-
-// Write a byte to the socket.
-void
-java::net::PlainSocketImpl::write(jint b)
-{
-  jbyte d =(jbyte) b;
-  int r = 0;
-
-  while (r != 1)
-    {
-      r = _Jv_write (fnum, &d, 1);
-      if (r == -1)
-        {
-          if (java::lang::Thread::interrupted())
-            {
-              java::io::InterruptedIOException *iioe
-                = new java::io::InterruptedIOException 
-                (JvNewStringLatin1 (strerror (errno)));
-              iioe->bytesTransferred = 0;
-              throw iioe;
-            }
-          // Some errors should not cause exceptions.
-          if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
-            throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
-          break;
-        }
-    }
-}
-
-// Write some bytes to the socket.
-void
-java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
-{
-  if (! b)
-    throw new java::lang::NullPointerException;
-  if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
-    throw new java::lang::ArrayIndexOutOfBoundsException;
-
-  jbyte *bytes = elements (b) + offset;
-  int written = 0;
-
-  while (len > 0)
-    {
-      int r = _Jv_write (fnum, bytes, len);
-
-      if (r == -1)
-        {
-          if (java::lang::Thread::interrupted())
-            {
-              java::io::InterruptedIOException *iioe
-                = new java::io::InterruptedIOException
-                (JvNewStringLatin1 (strerror (errno)));
-              iioe->bytesTransferred = written;
-              throw iioe;
-            }
-          // Some errors should not cause exceptions.
-          if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
-            throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
-          break;
-        }
-
-      written += r;
-      len -= r;
-      bytes += r;
-    }
-}
-
-void
-java::net::PlainSocketImpl::sendUrgentData (jint)
-{
-  throw new SocketException (JvNewStringLatin1 (
-    "PlainSocketImpl: sending of urgent data not supported by this socket"));
-}
-
-// Read a single byte from the socket.
-jint
-java::net::PlainSocketImpl::read(void)
-{
-  jbyte b;
-
-  // Do timeouts via select.
-  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
-    {
-      // Create the file descriptor set.
-      fd_set read_fds;
-      FD_ZERO (&read_fds);
-      FD_SET (fnum,&read_fds);
-      // Create the timeout struct based on our internal timeout value.
-      struct timeval timeout_value;
-      timeout_value.tv_sec = timeout / 1000;
-      timeout_value.tv_usec = (timeout % 1000) * 1000;
-      // Select on the fds.
-      int sel_retval =
-        _Jv_select (fnum + 1, &read_fds, NULL, NULL, &timeout_value);
-      // If select returns 0 we've waited without getting data...
-      // that means we've timed out.
-      if (sel_retval == 0)
-        throw new java::net::SocketTimeoutException
-          (JvNewStringUTF ("read timed out") );
-      // If select returns ok we know we either got signalled or read some data...
-      // either way we need to try to read.
-    }
-
-  int r = _Jv_read (fnum, &b, 1);
-
-  if (r == 0)
-    return -1;
-
-  if (java::lang::Thread::interrupted())
-    {
-      java::io::InterruptedIOException *iioe =
-        new java::io::InterruptedIOException
-        (JvNewStringUTF("read interrupted"));
-      iioe->bytesTransferred = r == -1 ? 0 : r;
-      throw iioe;
-    }
-  else if (r == -1)
-    {
-      // Some errors cause us to return end of stream...
-      if (errno == ENOTCONN)
-        return -1;
-
-      // Other errors need to be signalled.
-      throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
-    }
-
-  return b & 0xFF;
-}
-
-// Read count bytes into the buffer, starting at offset.
-jint
-java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
-{
-  if (! buffer)
-    throw new java::lang::NullPointerException;
-
-  jsize bsize = JvGetArrayLength (buffer);
-
-  if (offset < 0 || count < 0 || offset + count > bsize)
-    throw new java::lang::ArrayIndexOutOfBoundsException;
-
-  jbyte *bytes = elements (buffer) + offset;
-
-  // Do timeouts via select.
-  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
-    {
-      // Create the file descriptor set.
-      fd_set read_fds;
-      FD_ZERO (&read_fds);
-      FD_SET (fnum, &read_fds);
-      // Create the timeout struct based on our internal timeout value.
-      struct timeval timeout_value;
-      timeout_value.tv_sec = timeout / 1000;
-      timeout_value.tv_usec =(timeout % 1000) * 1000;
-      // Select on the fds.
-      int sel_retval =
-        _Jv_select (fnum + 1, &read_fds, NULL, NULL, &timeout_value);
-      // We're only interested in the 0 return.
-      // error returns still require us to try to read 
-      // the socket to see what happened.
-      if (sel_retval == 0)
-        {
-          java::net::SocketTimeoutException *timeoutException =
-            new java::net::SocketTimeoutException
-            (JvNewStringUTF ("read timed out"));
-          throw timeoutException;
-        }
-    }
-
-  // Read the socket.
-  int r = ::recv (fnum, (char *) bytes, count, 0);
-
-  if (r == 0)
-    return -1;
-
-  if (java::lang::Thread::interrupted())
-    {
-      java::io::InterruptedIOException *iioe =
-        new java::io::InterruptedIOException
-        (JvNewStringUTF ("read interrupted"));
-      iioe->bytesTransferred = r == -1 ? 0 : r;
-      throw iioe;
-    }
-  else if (r == -1)
-    {
-      // Some errors cause us to return end of stream...
-      if (errno == ENOTCONN)
-        return -1;
-
-      // Other errors need to be signalled.
-      throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
-    }
-
-  return r;
-}
-
-// How many bytes are available?
-jint
-java::net::PlainSocketImpl::available(void)
-{
-#if defined(FIONREAD) || defined(HAVE_SELECT)
-  long num = 0;
-  int r = 0;
-  bool num_set = false;
-
-#if defined(FIONREAD)
-  r = ::ioctl (fnum, FIONREAD, &num);
-
-  if (r == -1 && errno == ENOTTY)
-    {
-      // If the ioctl doesn't work, we don't care.
-      r = 0;
-      num = 0;
-    }
-  else
-    num_set = true;
-#elif defined(HAVE_SELECT)
-  if (fnum < 0)
-    {
-      errno = EBADF;
-      r = -1;
-    }
-#endif
-
-  if (r == -1)
-    {
-    posix_error:
-      throw new java::io::IOException(JvNewStringUTF(strerror(errno)));
-    }
-
-  // If we didn't get anything we can use select.
-
-#if defined(HAVE_SELECT)
-  if (! num_set)
-    if (! num_set && fnum >= 0 && fnum < FD_SETSIZE)
-      {
-        fd_set rd;
-        FD_ZERO (&rd);
-        FD_SET (fnum, &rd);
-        struct timeval tv;
-        tv.tv_sec = 0;
-        tv.tv_usec = 0;
-        r = _Jv_select (fnum + 1, &rd, NULL, NULL, &tv);
-        if(r == -1)
-          goto posix_error;
-        num = r == 0 ? 0 : 1;
-      }
-#endif /* HAVE_SELECT */
-
-  return (jint) num;
-#else
-  throw new java::io::IOException (JvNewStringUTF ("unimplemented"));
-#endif
-}
-
-void
-java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value)
-{
-  int val;
-  socklen_t val_len = sizeof (val);
-
-  if (fnum < 0)
-    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
-
-  if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
-    {
-      java::lang::Boolean *boolobj = 
-        static_cast<java::lang::Boolean *> (value);
-      if (boolobj->booleanValue())
-        val = 1; 
-      else 
-        {
-          if (optID == _Jv_SO_LINGER_)
-            val = -1;
-          else
-            val = 0;
-        }
-    }
-  else if (_Jv_IsInstanceOf (value, &java::lang::Integer::class$))
-    {
-      java::lang::Integer *intobj = 
-        static_cast<java::lang::Integer *> (value);          
-      val = (int) intobj->intValue();
-    }
-  else
-    {
-      throw new java::lang::IllegalArgumentException (
-        JvNewStringLatin1 ("`value' must be Boolean or Integer"));
-    }
-
-  switch (optID) 
-    {
-      case _Jv_TCP_NODELAY_ :
-#ifdef TCP_NODELAY
-        if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
-                          val_len) != 0)
-          goto error;
-#else
-        throw new java::lang::InternalError
-          (JvNewStringUTF ("TCP_NODELAY not supported"));
-#endif /* TCP_NODELAY */
-        return;
-
-      case _Jv_SO_KEEPALIVE_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
-                          val_len) != 0)
-          goto error;
-        break;
-      
-      case _Jv_SO_BROADCAST_ :
-        throw new java::net::SocketException
-          (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
-        break;
-	
-      case _Jv_SO_OOBINLINE_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
-                          val_len) != 0)
-          goto error;
-        break;
-
-      case _Jv_SO_LINGER_ :
-#ifdef SO_LINGER
-        struct linger l_val;
-        l_val.l_onoff = (val != -1);
-        l_val.l_linger = val;
-
-        if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
-                          sizeof(l_val)) != 0)
-          goto error;    
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_LINGER not supported"));
-#endif /* SO_LINGER */
-        return;
-
-      case _Jv_SO_SNDBUF_ :
-      case _Jv_SO_RCVBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
-          goto error;    
-#else
-        throw new java::lang::InternalError (
-          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
-#endif 
-        return;
-
-      case _Jv_SO_BINDADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_BINDADDR: read only option"));
-        return;
-
-      case _Jv_IP_MULTICAST_IF_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
-        return;
-	
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
-        break;
-	
-      case _Jv_IP_MULTICAST_LOOP_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
-        break;
-	
-      case _Jv_IP_TOS_ :
-        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-                          val_len) != 0)
-          goto error;    
-        break;
-	
-      case _Jv_SO_REUSEADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
-        return;
-
-      case _Jv_SO_TIMEOUT_ :
-        timeout = val;
-        return;
-
-      default :
-        errno = ENOPROTOOPT;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::SocketException (JvNewStringUTF (strerr));
-}
-
-java::lang::Object *
-java::net::PlainSocketImpl::getOption (jint optID)
-{
-  int val;
-  socklen_t val_len = sizeof(val);
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  struct linger l_val;
-  socklen_t l_val_len = sizeof(l_val);
-
-  switch (optID)
-    {
-#ifdef TCP_NODELAY
-    case _Jv_TCP_NODELAY_ :
-      if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
-                        &val_len) != 0)
-        goto error;
-      else
-        return new java::lang::Boolean (val != 0);
-#else
-      throw new java::lang::InternalError
-        (JvNewStringUTF ("TCP_NODELAY not supported"));
-#endif       
-      break;
-      
-    case _Jv_SO_LINGER_ :
-#ifdef SO_LINGER
-      if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
-                        &l_val_len) != 0)
-        goto error;    
- 
-      if (l_val.l_onoff)
-        return new java::lang::Integer (l_val.l_linger);
-      else
-        return new java::lang::Boolean ((jboolean)false);
-#else
-      throw new java::lang::InternalError
-        (JvNewStringUTF ("SO_LINGER not supported"));
-#endif
-      break;    
-
-    case _Jv_SO_KEEPALIVE_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
-                        &val_len) != 0)
-        goto error;
-      else
-        return new java::lang::Boolean (val != 0);
-
-    case _Jv_SO_BROADCAST_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-                        &val_len) != 0)
-        goto error;    
-      return new java::lang::Boolean ((jboolean)val);
-	
-    case _Jv_SO_OOBINLINE_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
-                        &val_len) != 0)
-        goto error;    
-      return new java::lang::Boolean ((jboolean)val);
-	
-    case _Jv_SO_RCVBUF_ :
-    case _Jv_SO_SNDBUF_ :
-#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
-      int opt;
-      optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-      if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
-        goto error;    
-      else
-        return new java::lang::Integer (val);
-#else
-      throw new java::lang::InternalError
-        (JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
-#endif    
-      break;
-    case _Jv_SO_BINDADDR_:
-      // cache the local address 
-      if (localAddress == NULL)
-        {
-          jbyteArray laddr;
-
-          if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
-            goto error;
-
-          if (u.address.sin_family == AF_INET)
-            {
-              laddr = JvNewByteArray (4);
-              memcpy (elements (laddr), &u.address.sin_addr, 4);
-            }
-#ifdef HAVE_INET6
-          else if (u.address.sin_family == AF_INET6)
-            {
-              laddr = JvNewByteArray (16);
-              memcpy (elements (laddr), &u.address6.sin6_addr, 16);
-            }
-#endif
-          else
-            throw new java::net::SocketException
-              (JvNewStringUTF ("invalid family"));
-          localAddress = new java::net::InetAddress (laddr, NULL);
-        }
-
-      return localAddress;
-      break;
-    case _Jv_IP_MULTICAST_IF_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
-      break;
-	
-    case _Jv_IP_MULTICAST_IF2_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
-      break;
-	
-    case _Jv_IP_MULTICAST_LOOP_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
-      break;
-	
-    case _Jv_IP_TOS_ :
-      if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-                        &val_len) != 0)
-        goto error;
-      return new java::lang::Integer (val);
-      break;
-	
-    case _Jv_SO_REUSEADDR_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
-      break;
-
-    case _Jv_SO_TIMEOUT_ :
-      return new java::lang::Integer (timeout);
-      break;
-
-    default :
-      errno = ENOPROTOOPT;
-    }
-
- error:
-  char* strerr = strerror (errno);
-  throw new java::net::SocketException (JvNewStringUTF (strerr));
-}
-
-void
-java::net::PlainSocketImpl::shutdownInput (void)
-{
-  if (::shutdown (fnum, 0))
-    throw new SocketException (JvNewStringUTF (strerror (errno)));
-}
-
-void
-java::net::PlainSocketImpl::shutdownOutput (void)
-{
-  if (::shutdown (fnum, 1))
-    throw new SocketException (JvNewStringUTF (strerror (errno)));
-}
Index: java/net/natPlainSocketImplWin32.cc
===================================================================
RCS file: java/net/natPlainSocketImplWin32.cc
diff -N java/net/natPlainSocketImplWin32.cc
--- java/net/natPlainSocketImplWin32.cc	29 Aug 2003 04:21:01 -0000	1.4
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,784 +0,0 @@
-/* Copyright (C) 2003 Free Software Foundation
-
-   This file is part of libgcj.
-
-This software is copyrighted work licensed under the terms of the
-Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
-details.  */
-
-#include <config.h>
-#include <platform.h>
-
-#undef STRICT
-#undef MAX_PRIORITY
-#undef MIN_PRIORITY
-
-#include <java/io/IOException.h>
-#include <java/io/InterruptedIOException.h>
-#include <java/net/BindException.h>
-#include <java/net/ConnectException.h>
-#include <java/net/PlainSocketImpl.h>
-#include <java/net/InetAddress.h>
-#include <java/net/InetSocketAddress.h>
-#include <java/net/SocketException.h>
-#include <java/net/SocketTimeoutException.h>
-#include <java/lang/InternalError.h>
-#include <java/lang/Object.h>
-#include <java/lang/Boolean.h>
-#include <java/lang/Class.h>
-#include <java/lang/Integer.h>
-#include <java/lang/Thread.h>
-#include <java/lang/NullPointerException.h>
-#include <java/lang/ArrayIndexOutOfBoundsException.h>
-#include <java/lang/IllegalArgumentException.h>
-
-union SockAddr
-{
-  struct sockaddr_in address;
-#ifdef HAVE_INET6
-  struct sockaddr_in6 address6;
-#endif
-};
-
-void
-java::net::PlainSocketImpl::create (jboolean stream)
-{
-  int sock = ::socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
-
-  if (sock == int(INVALID_SOCKET))
-    {
-      _Jv_ThrowIOException ();
-    }
-
-  _Jv_platform_close_on_exec (sock);
-
-  // We use fnum in place of fd here.  From leaving fd null we avoid
-  // the double close problem in FileDescriptor.finalize.
-  fnum = sock;
-}
-
-void
-java::net::PlainSocketImpl::bind (java::net::InetAddress *host, jint lport)
-{
-  union SockAddr u;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  int i = 1;
-
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-
-      if (host != NULL)
-        memcpy (&u.address.sin_addr, bytes, len);
-      else
-        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
-
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (lport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (lport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
-  ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
-
-  if (::bind (fnum, ptr, len) != SOCKET_ERROR)
-    {
-      address = host;
-      socklen_t addrlen = sizeof(u);
-
-      if (lport != 0)
-        localport = lport;
-      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
-        localport = ntohs (u.address.sin_port);
-      else
-        goto error;
-
-      return;
-    }
-
-error:
-  DWORD dwErrorCode = WSAGetLastError ();
-  throw new java::net::BindException (_Jv_WinStrError (dwErrorCode));
-}
-
-static void
-throwConnectException (DWORD dwErrorCode)
-{
-  throw new java::net::ConnectException (_Jv_WinStrError (dwErrorCode));
-}
-
-static void
-throwConnectException ()
-{
-  throwConnectException (WSAGetLastError ());
-}
-
-void
-java::net::PlainSocketImpl::connect (java::net::SocketAddress *addr,
-                                     jint timeout)
-{
-  java::net::InetSocketAddress *tmp = (java::net::InetSocketAddress*) addr;
-  java::net::InetAddress *host = tmp->getAddress();
-  jint rport = tmp->getPort();
-
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  jbyteArray haddress = host->addr;
-  jbyte *bytes = elements (haddress);
-  int len = haddress->length;
-  struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  
-  if (len == 4)
-    {
-      u.address.sin_family = AF_INET;
-      memcpy (&u.address.sin_addr, bytes, len);
-      len = sizeof (struct sockaddr_in);
-      u.address.sin_port = htons (rport);
-    }
-#ifdef HAVE_INET6
-  else if (len == 16)
-    {
-      u.address6.sin6_family = AF_INET6;
-      memcpy (&u.address6.sin6_addr, bytes, len);
-      len = sizeof (struct sockaddr_in6);
-      u.address6.sin6_port = htons (rport);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid length"));
-
-  if (timeout > 0)
-    {
-      // FIXME: we're creating a fresh WSAEVENT for each connect().
-      WSAEventWrapper aWSAEventWrapper(fnum, FD_CONNECT);
-      WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
-
-      if (::connect (fnum, ptr, len) == SOCKET_ERROR)
-      {
-        if (WSAGetLastError () != WSAEWOULDBLOCK)
-          throwConnectException ();
-
-        DWORD dwRet =
-          WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
-            // use true, false instead of TRUE, FALSE because the
-            // MS constants got undefined
-
-        if (dwRet == WSA_WAIT_FAILED)
-          throwConnectException ();
-        
-        else if (dwRet == WSA_WAIT_TIMEOUT)
-          throw new java::net::SocketTimeoutException
-            (JvNewStringUTF ("connect timed out"));
-            
-        // If we get here, we still need to check whether the actual
-        // connect() succeeded. Use any socket-specific error code
-        // instead of the thread-based one.
-        int nErrCode; int nErrLen=sizeof(nErrCode);
-        if (::getsockopt(fnum, SOL_SOCKET, SO_ERROR, (char*) &nErrCode,
-          &nErrLen) == SOCKET_ERROR)
-          {
-            throwConnectException ();
-          }
-        
-        if (nErrCode != NO_ERROR)
-          {
-            throwConnectException (nErrCode);
-          }
-      }
-    }
-  else
-    {
-      if (::connect (fnum, ptr, len) == SOCKET_ERROR)
-        throwConnectException();
-    }
-
-  address = host;
-  port = rport;
-
-  // A bind may not have been done on this socket; if so, set localport now.
-  if (localport == 0)
-    {
-      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
-        localport = ntohs (u.address.sin_port);
-      else
-        throwConnectException();
-    }
-}
-
-void
-java::net::PlainSocketImpl::listen (jint backlog)
-{
-  if (::listen (fnum, backlog) == SOCKET_ERROR)
-    {
-      _Jv_ThrowIOException ();
-    }
-}
-
-void
-java::net::PlainSocketImpl::accept (java::net::PlainSocketImpl *s)
-{
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  int new_socket = 0;
-
-  if (timeout > 0)
-    {
-      // FIXME: we're creating a fresh WSAEVENT for each accept().
-      // One possible alternative would be that fnum really points
-      // to an extended structure consisting of the SOCKET, its
-      // associated WSAEVENT, etc.
-      WSAEventWrapper aWSAEventWrapper(fnum, FD_ACCEPT);
-      WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
-
-      for (;;)
-      {
-        new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen);
-
-        if (new_socket != int(INVALID_SOCKET))
-        {
-          // This new child socket is nonblocking because the parent
-          // socket became nonblocking via the WSAEventSelect() call,
-          // so we set its mode back to blocking.
-          WSAEventSelect (new_socket, hEvent, 0);
-            // undo the hEvent <-> FD_ACCEPT association inherited
-            // inherited from our parent socket
-
-          unsigned long lSockOpt = 0L;
-            // blocking mode
-          if (ioctlsocket(new_socket, FIONBIO, &lSockOpt) == SOCKET_ERROR)
-          {
-            goto error;
-          }
-          break;
-        }
-        else if (WSAGetLastError () != WSAEWOULDBLOCK)
-          {
-            goto error;
-          }
-
-        DWORD dwRet =
-          WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
-            // use true, false instead of TRUE, FALSE because the
-            // MS constants got undefined
-
-        if (dwRet == WSA_WAIT_FAILED)
-          goto error;
-        else if (dwRet == WSA_WAIT_TIMEOUT)
-          throw new java::net::SocketTimeoutException
-            (JvNewStringUTF ("accept timed out"));
-      }
-    }
-  else
-    {
-      new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen);
-    }
-
-  if (new_socket == int(INVALID_SOCKET))
-    goto error;
-
-  _Jv_platform_close_on_exec (new_socket);
-
-  jbyteArray raddr;
-  jint rport;
-  if (u.address.sin_family == AF_INET)
-    {
-      raddr = JvNewByteArray (4);
-      memcpy (elements (raddr), &u.address.sin_addr, 4);
-      rport = ntohs (u.address.sin_port);
-    }
-#ifdef HAVE_INET6
-  else if (u.address.sin_family == AF_INET6)
-    {
-      raddr = JvNewByteArray (16);
-      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
-      rport = ntohs (u.address6.sin6_port);
-    }
-#endif
-  else
-    throw new java::net::SocketException (JvNewStringUTF ("invalid family"));
-
-  s->fnum = new_socket;
-  s->localport = localport;
-  s->address = new InetAddress (raddr, NULL);
-  s->port = rport;
-  return;
-
- error:
-  _Jv_ThrowIOException ();
-}
-
-// Close(shutdown) the socket.
-void
-java::net::PlainSocketImpl::close()
-{
-  // Avoid races from asynchronous finalization.
-  JvSynchronize sync (this);
-
-  // should we use shutdown here? how would that effect so_linger?
-  int res = ::closesocket (fnum);
-
-  if (res == -1)
-    {
-      // These three errors are not errors according to tests performed
-      // on the reference implementation.
-      DWORD dwErr = WSAGetLastError();
-      if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
-        && dwErr != WSAENOTSOCK)
-        _Jv_ThrowIOException ();
-    }
-  // Safe place to reset the file pointer.
-  fnum = -1;
-  timeout = 0;
-}
-
-// Write a byte to the socket.
-void
-java::net::PlainSocketImpl::write(jint b)
-{
-  jbyte d =(jbyte) b;
-  int r = 0;
-
-  while (r != 1)
-    {
-      r = ::send (fnum, (char*) &d, 1, 0);
-      if (r == -1)
-        {
-          DWORD dwErr = WSAGetLastError();
-          if (java::lang::Thread::interrupted())
-            {
-              java::io::InterruptedIOException *iioe
-                = new java::io::InterruptedIOException
-                (_Jv_WinStrError (dwErr));
-              iioe->bytesTransferred = 0;
-              throw iioe;
-            }
-          // Some errors should not cause exceptions.
-          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
-            && dwErr != WSAENOTSOCK)
-            _Jv_ThrowIOException ();
-          break;
-        }
-    }
-}
-
-// Write some bytes to the socket.
-void
-java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
-{
-  if (! b)
-    throw new java::lang::NullPointerException;
-  if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
-    throw new java::lang::ArrayIndexOutOfBoundsException;
-
-  jbyte *bytes = elements (b) + offset;
-  int written = 0;
-  while (len > 0)
-    {
-      int r = ::send (fnum, (char*) bytes, len, 0);
-
-      if (r == -1)
-        {
-          DWORD dwErr = WSAGetLastError();
-          if (java::lang::Thread::interrupted())
-            {
-              java::io::InterruptedIOException *iioe
-                = new java::io::InterruptedIOException
-                (_Jv_WinStrError (dwErr));
-              iioe->bytesTransferred = written;
-              throw iioe;
-            }
-          // Some errors should not cause exceptions.
-          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
-            && dwErr != WSAENOTSOCK)
-            _Jv_ThrowIOException ();
-          break;
-        }
-
-      written += r;
-      len -= r;
-      bytes += r;
-    }
-}
-
-void
-java::net::PlainSocketImpl::sendUrgentData (jint)
-{
-  throw new SocketException (JvNewStringLatin1 (
-    "PlainSocketImpl: sending of urgent data not supported by this socket"));
-}
-
-// read() helper
-static jint
-doRead(int fnum, void* buf, int count, int timeout)
-{
-  int r = 0;
-  DWORD dwErrorCode = 0;
-    // we are forced to declare this here because
-    // a call to Thread::interrupted() blanks out
-    // WSAGetLastError().
-
-  // FIXME: we unconditionally set SO_RCVTIMEO here
-  // because we can't detect whether someone has
-  // gone from a non-zero to zero timeout. What we'd
-  // really need is a member state variable in addition
-  // to timeout
-  int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
-    (char*)&timeout, sizeof(timeout));
-  if (nRet != NO_ERROR)
-  {
-    dwErrorCode = WSAGetLastError ();
-    goto error;
-  }
-  
-  r = ::recv (fnum, (char*) buf, count, 0);
-
-  if (r == 0)
-    return -1;
-
-  dwErrorCode = WSAGetLastError ();
-    // save WSAGetLastError() before calling Thread.interrupted()
-  
-  if (java::lang::Thread::interrupted())
-    {
-      java::io::InterruptedIOException *iioe =
-        new java::io::InterruptedIOException
-        (JvNewStringUTF("read interrupted"));
-      iioe->bytesTransferred = r == -1 ? 0 : r;
-      throw iioe;
-    }
-  else if (r == -1)
-    {
-error:
-      // Some errors cause us to return end of stream...
-      if (dwErrorCode == WSAENOTCONN)
-        return -1;
-
-      // Other errors need to be signalled.
-      if (dwErrorCode == WSAETIMEDOUT)
-        throw new java::net::SocketTimeoutException
-          (JvNewStringUTF ("read timed out") );
-      else
-        _Jv_ThrowIOException (dwErrorCode);
-    }
-    
-   return r;
-}
-
-// Read a single byte from the socket.
-jint
-java::net::PlainSocketImpl::read(void)
-{
-  jbyte b;
-  doRead(fnum, &b, 1, timeout);
-  return b & 0xFF;
-}
-
-// Read count bytes into the buffer, starting at offset.
-jint
-java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
-{
-  if (! buffer)
-    throw new java::lang::NullPointerException;
-
-  jsize bsize = JvGetArrayLength (buffer);
-
-  if (offset < 0 || count < 0 || offset + count > bsize)
-    throw new java::lang::ArrayIndexOutOfBoundsException;
-
-  jbyte *bytes = elements (buffer) + offset;
-
-  // Read the socket.
-  return doRead(fnum, bytes, count, timeout);
-}
-
-// How many bytes are available?
-jint
-java::net::PlainSocketImpl::available(void)
-{
-  unsigned long num = 0;
-
-  if (::ioctlsocket (fnum, FIONREAD, &num) == SOCKET_ERROR)
-    _Jv_ThrowIOException ();
-
-  return (jint) num;
-}
-
-void
-java::net::PlainSocketImpl::setOption (jint optID, java::lang::Object *value)
-{
-  int val;
-  socklen_t val_len = sizeof (val);
-
-  if (fnum < 0)
-    throw new java::net::SocketException (JvNewStringUTF ("Socket closed"));
-
-  if (_Jv_IsInstanceOf (value, &java::lang::Boolean::class$))
-    {
-      java::lang::Boolean *boolobj =
-        static_cast<java::lang::Boolean *> (value);
-      if (boolobj->booleanValue())
-        val = 1;
-      else
-        {
-          if (optID == _Jv_SO_LINGER_)
-            val = -1;
-          else
-            val = 0;
-        }
-    }
-  else if (_Jv_IsInstanceOf (value, &java::lang::Integer::class$))
-    {
-      java::lang::Integer *intobj =
-        static_cast<java::lang::Integer *> (value);
-      val = (int) intobj->intValue();
-    }
-  else
-    {
-      throw new java::lang::IllegalArgumentException (
-        JvNewStringLatin1 ("`value' must be Boolean or Integer"));
-    }
-
-  switch (optID)
-    {
-      case _Jv_TCP_NODELAY_ :
-        if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
-                          val_len) == SOCKET_ERROR)
-          goto error;
-        return;
-
-      case _Jv_SO_KEEPALIVE_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
-                          val_len) == SOCKET_ERROR)
-          goto error;
-        break;
-
-      case _Jv_SO_BROADCAST_ :
-        throw new java::net::SocketException
-          (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
-        break;
-
-      case _Jv_SO_OOBINLINE_ :
-        if (::setsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
-                          val_len) == SOCKET_ERROR)
-          goto error;
-        break;
-
-      case _Jv_SO_LINGER_ :
-        struct linger l_val;
-        l_val.l_onoff = (val != -1);
-        l_val.l_linger = val;
-
-        if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
-                          sizeof(l_val)) == SOCKET_ERROR)
-          goto error;
-        return;
-
-      case _Jv_SO_SNDBUF_ :
-      case _Jv_SO_RCVBUF_ :
-        int opt;
-        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val,
-                          val_len) == SOCKET_ERROR)
-          goto error;
-        return;
-
-      case _Jv_SO_BINDADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_BINDADDR: read only option"));
-        return;
-
-      case _Jv_IP_MULTICAST_IF_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
-        return;
-
-      case _Jv_IP_MULTICAST_IF2_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
-        break;
-
-      case _Jv_IP_MULTICAST_LOOP_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
-        break;
-
-      case _Jv_IP_TOS_ :
-        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-                          val_len) == SOCKET_ERROR)
-          goto error;
-        break;
-
-      case _Jv_SO_REUSEADDR_ :
-        throw new java::net::SocketException (
-          JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
-        return;
-
-      case _Jv_SO_TIMEOUT_ :
-        timeout = val;
-        return;
-
-      default :
-        WSASetLastError (WSAENOPROTOOPT);
-    }
-
-error:
-  _Jv_ThrowSocketException ();
-}
-
-java::lang::Object *
-java::net::PlainSocketImpl::getOption (jint optID)
-{
-  int val;
-  socklen_t val_len = sizeof(val);
-  union SockAddr u;
-  socklen_t addrlen = sizeof(u);
-  struct linger l_val;
-  socklen_t l_val_len = sizeof(l_val);
-
-  switch (optID)
-    {
-    case _Jv_TCP_NODELAY_ :
-      if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      else
-        return new java::lang::Boolean (val != 0);
-      break;
-
-    case _Jv_SO_LINGER_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
-                        &l_val_len) == SOCKET_ERROR)
-        goto error;
-
-      if (l_val.l_onoff)
-        return new java::lang::Integer (l_val.l_linger);
-      else
-        return new java::lang::Boolean ((jboolean)false);
-      break;
-
-    case _Jv_SO_KEEPALIVE_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      else
-        return new java::lang::Boolean (val != 0);
-
-    case _Jv_SO_BROADCAST_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      return new java::lang::Boolean ((jboolean)val);
-
-    case _Jv_SO_OOBINLINE_ :
-      if (::getsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      return new java::lang::Boolean ((jboolean)val);
-
-    case _Jv_SO_RCVBUF_ :
-    case _Jv_SO_SNDBUF_ :
-      int opt;
-      optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
-      if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      else
-        return new java::lang::Integer (val);
-      break;
-    case _Jv_SO_BINDADDR_:
-      // cache the local address
-      if (localAddress == NULL)
-        {
-          jbyteArray laddr;
-
-          if (::getsockname (fnum, (sockaddr*) &u,
-                             &addrlen) == SOCKET_ERROR)
-            goto error;
-
-          if (u.address.sin_family == AF_INET)
-            {
-              laddr = JvNewByteArray (4);
-              memcpy (elements (laddr), &u.address.sin_addr, 4);
-            }
-#ifdef HAVE_INET6
-          else if (u.address.sin_family == AF_INET6)
-            {
-              laddr = JvNewByteArray (16);
-              memcpy (elements (laddr), &u.address6.sin6_addr, 16);
-            }
-#endif
-          else
-            throw new java::net::SocketException
-              (JvNewStringUTF ("invalid family"));
-          localAddress = new java::net::InetAddress (laddr, NULL);
-        }
-
-      return localAddress;
-      break;
-    case _Jv_IP_MULTICAST_IF_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
-      break;
-
-    case _Jv_IP_MULTICAST_IF2_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
-      break;
-
-    case _Jv_IP_MULTICAST_LOOP_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
-      break;
-
-    case _Jv_IP_TOS_ :
-      if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
-                        &val_len) == SOCKET_ERROR)
-        goto error;
-      return new java::lang::Integer (val);
-      break;
-
-    case _Jv_SO_REUSEADDR_ :
-      throw new java::net::SocketException
-        (JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
-      break;
-
-    case _Jv_SO_TIMEOUT_ :
-      return new java::lang::Integer (timeout);
-      break;
-
-    default :
-      WSASetLastError (WSAENOPROTOOPT);
-    }
-
-error:
-  _Jv_ThrowSocketException ();
-  return 0;
-    // we should never get here
-}
-
-void
-java::net::PlainSocketImpl::shutdownInput (void)
-{
-  if (::shutdown (fnum, 0))
-    _Jv_ThrowSocketException ();
-}
-
-void
-java::net::PlainSocketImpl::shutdownOutput (void)
-{
-  if (::shutdown (fnum, 1))
-    _Jv_ThrowSocketException ();
-}
Index: gnu/java/net/PlainDatagramSocketImpl.java
===================================================================
RCS file: gnu/java/net/PlainDatagramSocketImpl.java
diff -N gnu/java/net/PlainDatagramSocketImpl.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/PlainDatagramSocketImpl.java	6 Sep 2003 16:09:13 -0000
@@ -0,0 +1,280 @@
+/* PlainDatagramSocketImpl.java -- Default DatagramSocket implementation
+   Copyright (C) 1998, 1999, 2001, 2003 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocketImpl;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketAddress;
+import java.net.SocketOptions;
+import java.net.SocketException;
+import gnu.classpath.Configuration;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * This is the default socket implementation for datagram sockets.
+ * It makes native calls to C routines that implement BSD style
+ * SOCK_DGRAM sockets in the AF_INET family.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @author Warren Levy <warrenl@cygnus.com>
+ */
+public final class PlainDatagramSocketImpl extends DatagramSocketImpl
+{
+  // Static initializer to load native library
+  static
+  {
+    if (Configuration.INIT_LOAD_LIBRARY)
+      {
+        System.loadLibrary("javanet");
+      }
+  }
+  
+  // These fields are mirrored for use in native code to avoid cpp conflicts
+  // when the #defines in system header files are the same as the public fields.
+  static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
+                   _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
+                   _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
+                   _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
+                   _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
+                   _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
+                   _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
+                   _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
+                   _Jv_IP_TOS_ = SocketOptions.IP_TOS,
+                   _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
+                   _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
+                   _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
+                   _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
+                   _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
+
+  /**
+   * This is the actual underlying file descriptor
+   */
+  int fnum = -1;
+
+  // FIXME: Is this necessary?  Could it help w/ DatagramSocket.getLocalAddress?
+  // InetAddress address;
+  
+  // localAddress cache  
+  InetAddress localAddress;
+
+  // 'timeout' is set/read by setOption/getOption.
+  int timeout = 0;
+
+  /**
+   * Default do nothing constructor
+   */
+  public PlainDatagramSocketImpl()
+  {
+  }
+
+  /**
+   * Binds this socket to a particular port and interface
+   *
+   * @param port The port to bind to
+   * @param addr The address to bind to
+   *
+   * @exception SocketException If an error occurs
+   */
+  protected native void bind(int lport, InetAddress laddr)
+	throws SocketException;
+
+  protected native void connect (InetAddress i, int port)
+	throws SocketException;
+  
+  protected native void disconnect ();
+  
+  /**
+   * Creates a new datagram socket
+   *
+   * @exception SocketException If an error occurs
+   */
+  protected native void create() throws SocketException;
+  
+  protected native int peek(InetAddress i) throws IOException;
+  
+  protected native int peekData (DatagramPacket dp) throws IOException;
+
+  /**
+   * Sets the Time to Live value for the socket
+   *
+   * @param ttl The new TTL value
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native void setTimeToLive(int ttl) throws IOException;
+
+  /**
+   * Gets the Time to Live value for the socket
+   *
+   * @return The TTL value
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native int getTimeToLive() throws IOException;
+
+  /**
+   * Sends a packet of data to a remote host
+   *
+   * @param packet The packet to send
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native void send(DatagramPacket p) throws IOException;
+
+  /**
+   * Receives a UDP packet from the network
+   *
+   * @param packet The packet to fill in with the data received
+   *
+   * @exception IOException IOException If an error occurs
+   */
+  protected native void receive(DatagramPacket p) throws IOException;
+
+  /**
+   * 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
+   *
+   * @exception SocketException If an error occurs
+   */
+  public native void setOption(int optID, Object value) throws SocketException;
+
+  /**
+   * Retrieves the value of an option on the socket
+   *
+   * @param option_id The identifier of the option to retrieve
+   *
+   * @return The value of the option
+   *
+   * @exception SocketException If an error occurs
+   */
+  public native Object getOption(int optID) throws SocketException;
+  
+  private native void mcastGrp(InetAddress inetaddr, NetworkInterface netIf,
+		               boolean join) throws IOException;
+
+  /**
+   * Closes the socket
+   */
+  protected native void close();
+
+  /**
+   * Gets the Time to Live value for the socket
+   *
+   * @return The TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @deprecated 1.2
+   */
+  protected byte getTTL() throws IOException
+  {
+    return (byte) getTimeToLive();
+  }
+
+  /**
+   * Sets the Time to Live value for the socket
+   *
+   * @param ttl The new TTL value
+   *
+   * @exception IOException If an error occurs
+   *
+   * @deprecated 1.2
+   */
+  protected void setTTL(byte ttl) throws IOException
+  {
+    setTimeToLive(((int) ttl) & 0xFF);
+  }
+
+  /**
+   * Joins a multicast group
+   *
+   * @param addr The group to join
+   *
+   * @exception IOException If an error occurs
+   */
+  protected void join(InetAddress inetaddr) throws IOException
+  {
+    mcastGrp(inetaddr, null, true);
+  }
+
+  /**
+   * Leaves a multicast group
+   *
+   * @param addr The group to leave
+   *
+   * @exception IOException If an error occurs
+   */
+  protected void leave(InetAddress inetaddr) throws IOException
+  {
+    mcastGrp(inetaddr, null, false);
+  }
+
+  protected void joinGroup (SocketAddress mcastaddr, NetworkInterface netIf)
+	  throws IOException
+  {
+    mcastGrp(((InetSocketAddress)mcastaddr).getAddress(), netIf, true);
+  }
+
+  protected void leaveGroup (SocketAddress mcastaddr, NetworkInterface netIf)
+	  throws IOException
+  {
+    mcastGrp(((InetSocketAddress)mcastaddr).getAddress(), netIf, false);
+  }
+
+  protected void finalize() throws Throwable
+  {
+    synchronized (this)
+      {
+	if (fnum != -1)
+	  close();
+      }
+    super.finalize();
+  }
+}
Index: gnu/java/net/PlainSocketImpl.java
===================================================================
RCS file: gnu/java/net/PlainSocketImpl.java
diff -N gnu/java/net/PlainSocketImpl.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/PlainSocketImpl.java	6 Sep 2003 16:09:13 -0000
@@ -0,0 +1,401 @@
+/* PlainSocketImpl.java -- Default socket implementation
+   Copyright (C) 1998, 1999, 2003 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 java.io.InputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.SocketImpl;
+import java.net.SocketOptions;
+import gnu.classpath.Configuration;
+
+/**
+ * Written using on-line Java Platform 1.2 API Specification, as well
+ * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
+ * Status:  Believed complete and correct.
+ */
+
+/**
+ * Unless the application installs its own SocketImplFactory, this is the
+ * default socket implemetation that will be used.  It simply uses a
+ * combination of Java and native routines to implement standard BSD
+ * style sockets of family AF_INET and types SOCK_STREAM and SOCK_DGRAM
+ *
+ * @author Per Bothner <bothner@cygnus.com>
+ * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ */
+public final class PlainSocketImpl extends SocketImpl
+{
+  // Static initializer to load native library.
+  static
+    {
+      if (Configuration.INIT_LOAD_LIBRARY)
+        {
+          System.loadLibrary("javanet");
+        }
+    }
+  
+  // These fields are mirrored for use in native code to avoid cpp conflicts
+  // when the #defines in system header files are the same as the public fields.
+  static final int _Jv_TCP_NODELAY_ = SocketOptions.TCP_NODELAY,
+                   _Jv_SO_BINDADDR_ = SocketOptions.SO_BINDADDR,
+                   _Jv_SO_REUSEADDR_ = SocketOptions.SO_REUSEADDR,
+                   _Jv_SO_BROADCAST_ = SocketOptions.SO_BROADCAST,
+                   _Jv_SO_OOBINLINE_ = SocketOptions.SO_OOBINLINE,
+                   _Jv_IP_MULTICAST_IF_ = SocketOptions.IP_MULTICAST_IF,
+                   _Jv_IP_MULTICAST_IF2_ = SocketOptions.IP_MULTICAST_IF2,
+                   _Jv_IP_MULTICAST_LOOP_ = SocketOptions.IP_MULTICAST_LOOP,
+                   _Jv_IP_TOS_ = SocketOptions.IP_TOS,
+                   _Jv_SO_LINGER_ = SocketOptions.SO_LINGER,
+                   _Jv_SO_TIMEOUT_ = SocketOptions.SO_TIMEOUT,
+                   _Jv_SO_SNDBUF_ = SocketOptions.SO_SNDBUF,
+                   _Jv_SO_RCVBUF_ = SocketOptions.SO_RCVBUF,
+                   _Jv_SO_KEEPALIVE_ = SocketOptions.SO_KEEPALIVE;
+
+  /**
+   * The OS file handle representing the socket.
+   * This is used for reads and writes to/from the socket and
+   * to close it.
+   *
+   * When the socket is closed this is reset to -1.
+   */
+  int fnum = -1;
+
+  // This value is set/read by setOption/getOption.
+  int timeout = 0;
+  
+  // localAddress cache
+  InetAddress localAddress;
+
+  /**
+   * A cached copy of the in stream for reading from the socket.
+   */
+  private InputStream in;
+
+  /**
+   * A cached copy of the out stream for writing to the socket.
+   */
+  private OutputStream out;
+
+  /**
+   * Default do nothing constructor
+   */
+  public PlainSocketImpl()
+  {
+  }
+  
+  protected void finalize() throws Throwable
+  {
+    synchronized (this)
+      {
+	if (fnum != -1)
+	  try
+	    {
+	      close();
+	    }
+	  catch (IOException ex)
+	    {
+	      // ignore
+	    }
+      }
+    super.finalize();
+  }
+
+  /**
+   * Sets the specified option on a socket to the passed in object.  For
+   * options that take an integer argument, the passed in object is an
+   * Integer.  The option_id parameter is one of the defined constants in
+   * this interface.
+   *
+   * @param option_id The identifier of the option
+   * @param val The value to set the option to
+   *
+   * @exception SocketException If an error occurs
+   */
+  public native void setOption(int optID, Object value) throws SocketException;
+
+  /**
+   * Returns the current setting of the specified option.  The Object returned
+   * will be an Integer for options that have integer values.  The option_id
+   * is one of the defined constants in this interface.
+   *
+   * @param option_id The option identifier
+   *
+   * @return The current value of the option
+   *
+   * @exception SocketException If an error occurs
+   */
+  public native Object getOption(int optID) throws SocketException;
+
+  public native void shutdownInput () throws IOException;
+
+  public native void shutdownOutput () throws IOException;
+
+  /**
+   * Creates a new socket that is not bound to any local address/port and
+   * is not connected to any remote address/port.  This will be created as
+   * a stream socket if the stream parameter is true, or a datagram socket
+   * if the stream parameter is false.
+   *
+   * @param stream true for a stream socket, false for a datagram socket
+   */
+  protected native void create (boolean stream)  throws IOException;
+
+  /**
+   * Connects to the remote hostname and port specified as arguments.
+   *
+   * @param hostname The remote hostname to connect to
+   * @param port The remote port to connect to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected void connect (String host, int port) throws IOException
+  {
+    connect (new InetSocketAddress (InetAddress.getByName(host), port), 0);
+  }
+
+  /**
+   * Connects to the remote address and port specified as arguments.
+   *
+   * @param addr The remote address to connect to
+   * @param port The remote port to connect to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected void connect (InetAddress host, int port) throws IOException
+  {
+    connect (new InetSocketAddress (host, port), 0);
+  }
+
+  protected native void connect (SocketAddress addr, int timeout)
+    throws IOException;
+
+  /**
+   * Binds to the specified port on the specified addr.  Note that this addr
+   * must represent a local IP address.  **** How bind to INADDR_ANY? ****
+   *
+   * @param addr The address to bind to
+   * @param port The port number to bind to
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native void bind (InetAddress host, int port) throws IOException;
+
+  /**
+   * Starts listening for connections on a socket. The queuelen parameter
+   * is how many pending connections will queue up waiting to be serviced
+   * before being accept'ed.  If the queue of pending requests exceeds this
+   * number, additional connections will be refused.
+   *
+   * @param queuelen The length of the pending connection queue
+   * 
+   * @exception IOException If an error occurs
+   */
+  protected native void listen (int backlog) throws IOException;
+
+  private native void accept (PlainSocketImpl s) throws IOException;
+
+  /**
+   * Accepts a new connection on this socket and returns in in the 
+   * passed in SocketImpl.
+   *
+   * @param impl The SocketImpl object to accept this connection.
+   */
+  protected void accept (SocketImpl s) throws IOException
+  {
+    accept((PlainSocketImpl) s);
+  }
+
+  /**
+   * Returns the number of bytes that the caller can read from this socket
+   * without blocking. 
+   *
+   * @return The number of readable bytes before blocking
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native int available() throws IOException;
+
+  /**
+   * Closes the socket.  This will cause any InputStream or OutputStream
+   * objects for this Socket to be closed as well.
+   * <p>
+   * Note that if the SO_LINGER option is set on this socket, then the
+   * operation could block.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected native void close () throws IOException;
+
+  protected native void sendUrgentData(int data)
+    throws IOException;
+
+  native int read() throws IOException;
+
+  /**
+   * Internal method used by SocketInputStream for reading data from
+   * the connection.  Reads up to len bytes of data into the buffer
+   * buf starting at offset bytes into the buffer.
+   *
+   * @return The actual number of bytes read or -1 if end of stream.
+   *
+   * @exception IOException If an error occurs
+   */
+  native int read(byte[] buffer, int offset, int count)
+    throws IOException;
+
+  native void write(int c) throws IOException;
+
+  /**
+   * Internal method used by SocketOuputStream for writing data to
+   * the connection.  Writes up to len bytes of data from the buffer
+   * buf starting at offset bytes into the buffer.
+   *
+   * @exception IOException If an error occurs
+   */
+  native void write(byte[] buffer, int offset, int count)
+    throws IOException;
+
+  /**
+   * Returns an InputStream object for reading from this socket.  This will
+   * be an instance of SocketInputStream.
+   *
+   * @return An input stream attached to the socket.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected synchronized InputStream getInputStream() throws IOException
+  {
+    if (in == null)
+      in = new SocketInputStream();
+    
+    return in;
+  }
+
+  /**
+   * Returns an OutputStream object for writing to this socket.  This will
+   * be an instance of SocketOutputStream.
+   *
+   * @return An output stream attached to the socket.
+   *
+   * @exception IOException If an error occurs
+   */
+  protected synchronized OutputStream getOutputStream() throws IOException
+  {
+    if (out == null)
+      out = new SocketOutputStream();
+    
+    return out;
+  }
+
+  /**
+   * A stream which reads from the socket implementation.
+   *
+   * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
+   */
+  class SocketInputStream
+    extends InputStream
+  {
+    SocketInputStream()
+    {
+    }
+    
+    public final void close() throws IOException
+    {
+      PlainSocketImpl.this.close();
+    }
+
+    public final int available() throws IOException
+    {
+      return PlainSocketImpl.this.available();
+    }
+
+    public final int read() throws IOException
+    {
+      return PlainSocketImpl.this.read();
+    }
+
+    public final int read(byte[] buffer, int offset, int length)
+      throws IOException
+    {
+      return PlainSocketImpl.this.read(buffer, offset, length);
+    }
+
+    public final int read(byte[] buffer)
+      throws IOException
+    {
+      return PlainSocketImpl.this.read(buffer, 0, buffer.length);
+    }
+  }
+
+  /** A stream which writes to the socket implementation.
+   *
+   * @author Nic Ferrier  <nferrier@tapsellferrier.co.uk>
+   */
+  class SocketOutputStream
+    extends OutputStream
+  {
+    public final void close() throws IOException
+    {
+      PlainSocketImpl.this.close();
+    }
+
+    public final void write(int c) throws IOException
+    {
+      PlainSocketImpl.this.write(c);
+    }
+
+    public final void write(byte[] buffer, int offset, int length)
+      throws IOException
+    {
+      PlainSocketImpl.this.write(buffer, offset, length);
+    }
+
+    public final void write(byte[] buffer)
+      throws IOException
+    {
+      PlainSocketImpl.this.write(buffer, 0, buffer.length);
+    }
+  }
+}
Index: gnu/java/net/SocketInputStream.java
===================================================================
RCS file: gnu/java/net/SocketInputStream.java
diff -N gnu/java/net/SocketInputStream.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/SocketInputStream.java	6 Sep 2003 16:09:13 -0000
@@ -0,0 +1,204 @@
+/* SocketInputStream.java -- An InputStream for Sockets
+   Copyright (C) 1998, 2000, 2002 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 java.io.InputStream;
+import java.io.IOException;
+
+/**
+  * This class contains an implementation of <code>InputStream</code> for 
+  * sockets.  It in an internal only class used by <code>PlainSocketImpl</code>.
+  *
+  * @author Aaron M. Renn (arenn@urbanophile.com)
+  */
+class SocketInputStream extends InputStream
+{
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+  * The PlainSocketImpl object this stream is associated with
+  */
+private PlainSocketImpl impl;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+  * Builds an instance of this class from a PlainSocketImpl object
+  */
+protected
+SocketInputStream(PlainSocketImpl impl)
+{
+  this.impl = impl;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+  * Returns the number of bytes available to be read before blocking
+  */
+public int
+available() throws IOException
+{
+  return(impl.available());
+}
+
+/*************************************************************************/
+
+/**
+  * Determines if "mark" functionality is supported on this stream.  For
+  * sockets, this is always false.  Note that the superclass default is
+  * false, but it is overridden out of safety concerns and/or paranoia.
+  */
+public boolean
+markSupported()
+{
+  return(false);
+}
+
+/*************************************************************************/
+
+/**
+  * Do nothing mark method since we don't support this functionality.  Again,
+  * overriding out of paranoia.
+  *
+  * @param readlimit In theory, the number of bytes we can read before the mark becomes invalid
+  */
+public void
+mark(int readlimit)
+{
+}
+
+/*************************************************************************/
+
+/**
+  * Since we don't support mark, this method always throws an exception
+  *
+  * @exception IOException Everytime since we don't support this functionality
+  */
+public void
+reset() throws IOException
+{
+  throw new IOException("Socket InputStreams do not support mark/reset");
+}
+
+/*************************************************************************/
+
+/**
+  * This method not only closes the stream, it closes the underlying socket
+  * (and thus any connection) and invalidates any other Input/Output streams
+  * for the underlying impl object
+  */
+public void
+close() throws IOException
+{
+  impl.close();
+} 
+
+/*************************************************************************/
+
+/**
+  * Reads the next byte of data and returns it as an int.  
+  *
+  * @return The byte read (as an int) or -1 if end of stream);
+  *
+  * @exception IOException If an error occurs.
+  */
+public int
+read() throws IOException
+{
+  byte buf[] = new byte[1];
+
+  int bytes_read = read(buf, 0, buf.length);
+ 
+  if (bytes_read != -1)
+    return(buf[0] & 0xFF);
+  else
+    return(-1);
+}
+
+/*************************************************************************/
+
+/**
+  * Reads up to buf.length bytes of data into the caller supplied buffer.
+  *
+  * @return The actual number of bytes read or -1 if end of stream
+  *
+  * @exception IOException If an error occurs.
+  */
+public int
+read(byte[] buf) throws IOException
+{
+  return(read(buf, 0, buf.length));
+}
+
+/*************************************************************************/
+
+/**
+  * Reads up to len bytes of data into the caller supplied buffer starting
+  * at offset bytes from the start of the buffer
+  *
+  * @return The number of bytes actually read or -1 if end of stream
+  *
+  * @exception IOException If an error occurs.
+  */
+public int
+read(byte[] buf, int offset, int len) throws IOException
+{
+  int bytes_read = impl.read(buf, offset, len);
+  if (bytes_read == 0)
+    return(-1);
+
+  return(bytes_read);
+}
+
+} // class SocketInputStream
+
Index: gnu/java/net/SocketOutputStream.java
===================================================================
RCS file: gnu/java/net/SocketOutputStream.java
diff -N gnu/java/net/SocketOutputStream.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/SocketOutputStream.java	6 Sep 2003 16:09:13 -0000
@@ -0,0 +1,166 @@
+/* SocketOutputStream.java -- OutputStream for PlainSocketImpl
+   Copyright (C) 1998,2000 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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 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 java.io.OutputStream;
+import java.io.IOException;
+
+/**
+  * This class is used internally by <code>PlainSocketImpl</code> to be the 
+  * <code>OutputStream</code> subclass returned by its 
+  * <code>getOutputStream method</code>.  It expects only to  be used in that 
+  * context.
+  *
+  * @author Aaron M. Renn (arenn@urbanophile.com)
+  */
+class SocketOutputStream extends OutputStream
+{
+
+/*************************************************************************/
+
+/*
+ * Instance Variables
+ */
+
+/**
+  * The PlainSocketImpl object this stream is associated with
+  */
+private PlainSocketImpl impl;
+
+/*************************************************************************/
+
+/*
+ * Constructors
+ */
+
+/**
+  * Build an instance of this class from a PlainSocketImpl object
+  */
+protected
+SocketOutputStream(PlainSocketImpl impl)
+{
+  this.impl = impl;
+}
+
+/*************************************************************************/
+
+/*
+ * Instance Methods
+ */
+
+/**
+  * This method closes the stream and the underlying socket connection.  This
+  * action also effectively closes any other InputStream or OutputStream
+  * object associated with the connection.
+  *
+  * @exception IOException If an error occurs
+  */
+public void
+close() throws IOException
+{
+  impl.close();
+}
+
+/*************************************************************************/
+
+/**
+  * Hmmm, we don't seem to have a flush() method in Socket impl, so just
+  * return for now, but this might need to be looked at later.
+  *
+  * @exception IOException Can't happen
+  */
+public void
+flush() throws IOException
+{
+  return;
+}
+
+/*************************************************************************/
+
+/**
+  * Writes a byte (passed in as an int) to the given output stream
+  * 
+  * @param b The byte to write
+  *
+  * @exception IOException If an error occurs
+  */
+public void
+write(int b) throws IOException
+{
+  byte buf[] = new byte[1];
+
+  Integer i = new Integer(b);
+  buf[0] = i.byteValue();
+
+  write(buf, 0, buf.length);
+}
+
+/*************************************************************************/
+
+/**
+  * Write an array of bytes to the output stream
+  *
+  * @param buf The array of bytes to write
+  *
+  * @exception IOException If an error occurs
+  */
+public void
+write(byte[] buf) throws IOException
+{
+  write(buf, 0, buf.length);
+}
+
+/*************************************************************************/
+
+/**
+  * Writes len number of bytes from the array buf to the stream starting
+  * at offset bytes into the buffer.
+  *
+  * @param buf The buffer
+  * @param offset Offset into the buffer to start writing from
+  * @param len The number of bytes to write
+  */
+public void
+write(byte[] buf, int offset, int len) throws IOException
+{
+  impl.write(buf, offset, len);
+}
+
+} // class SocketOutputStream
+
Index: gnu/java/net/natPlainDatagramSocketImplNoNet.cc
===================================================================
RCS file: gnu/java/net/natPlainDatagramSocketImplNoNet.cc
diff -N gnu/java/net/natPlainDatagramSocketImplNoNet.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainDatagramSocketImplNoNet.cc	6 Sep 2003 16:09:13 -0000
@@ -0,0 +1,119 @@
+/* Copyright (C) 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/lang/Object.h>
+#include <java/net/BindException.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/SocketException.h>
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("DatagramSocketImpl.create: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint, ::java::net::InetAddress *)
+{
+  throw new ::java::net::BindException (
+    JvNewStringLatin1 ("DatagramSocketImpl.bind: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *, jint)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("DatagramSocketImpl.connect: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("DatagramSocketImpl.disconnect: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.peek: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.peekData: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.close: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.send: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.receive: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.setTimeToLive: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.getTimeToLive: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *,
+                                              ::java::net::NetworkInterface *,
+					      jboolean)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("DatagramSocketImpl.mcastGrp: unimplemented"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint, ::java::lang::Object *)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("DatagramSocketImpl.setOption: unimplemented"));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("DatagramSocketImpl.getOption: unimplemented"));
+}
Index: gnu/java/net/natPlainDatagramSocketImplPosix.cc
===================================================================
RCS file: gnu/java/net/natPlainDatagramSocketImplPosix.cc
diff -N gnu/java/net/natPlainDatagramSocketImplPosix.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainDatagramSocketImplPosix.cc	6 Sep 2003 16:09:14 -0000
@@ -0,0 +1,750 @@
+/* Copyright (C) 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#include <errno.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2 
+#include <bstring.h>
+#endif
+
+#include <gcj/cni.h>
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/SocketException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/PortUnreachableException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Integer.h>
+
+union SockAddr
+{
+  struct sockaddr_in address;
+#ifdef HAVE_INET6
+  struct sockaddr_in6 address6;
+#endif
+};
+
+union McastReq
+{
+#if HAVE_STRUCT_IP_MREQ
+  struct ip_mreq mreq;
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+  struct ipv6_mreq mreq6;
+#endif
+};
+
+union InAddr
+{
+  struct in_addr addr;
+#ifdef HAVE_INET6
+  struct in6_addr addr6;
+#endif
+};
+
+
+// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
+// NoRouteToHostException; also consider UnknownHostException, ConnectException.
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+  int sock = _Jv_socket (AF_INET, SOCK_DGRAM, 0);
+
+  if (sock < 0)
+    {
+      char* strerr = strerror (errno);
+      throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+    }
+
+  _Jv_platform_close_on_exec (sock);
+
+  // We use fnum in place of fd here.  From leaving fd null we avoid
+  // the double close problem in FileDescriptor.finalize.
+  fnum = sock;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint lport,
+                                               ::java::net::InetAddress *host)
+{
+  union SockAddr u;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+
+      if (host != NULL)
+        memcpy (&u.address.sin_addr, bytes, len);
+      else
+        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (lport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (lport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (_Jv_bind (fnum, ptr, len) == 0)
+    {
+      socklen_t addrlen = sizeof(u);
+
+      if (lport != 0)
+        localPort = lport;
+      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
+        localPort = ntohs (u.address.sin_port);
+      else
+        goto error;
+
+      /* Allow broadcast by default. */
+      int broadcast = 1;
+      if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast, 
+                        sizeof (broadcast)) != 0)
+        goto error;
+
+      return;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::BindException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *, jint)
+{ 
+  throw new ::java::lang::InternalError (JvNewStringLatin1 (
+	    "PlainDatagramSocketImpl::connect: not implemented yet"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+  throw new ::java::lang::InternalError (JvNewStringLatin1 (
+	    "PlainDatagramSocketImpl::disconnect: not implemented yet"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *i)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  ssize_t retlen =
+    ::recvfrom (fnum, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
+      &addrlen);
+  if (retlen < 0)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  i->addr = raddr;
+  return rport;
+ error:
+  char* strerr = strerror (errno);
+
+  if (errno == ECONNREFUSED)
+    throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData (::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyte *dbytes = elements (p->getData());
+  ssize_t retlen = 0;
+
+  // Do timeouts via select since SO_RCVTIMEO is not always available.
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
+    {
+      fd_set rset;
+      struct timeval tv;
+      FD_ZERO(&rset);
+      FD_SET(fnum, &rset);
+      tv.tv_sec = timeout / 1000;
+      tv.tv_usec = (timeout % 1000) * 1000;
+      int retval;
+      if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
+        goto error;
+      else if (retval == 0)
+        throw new ::java::io::InterruptedIOException ();
+    }
+
+  retlen =
+    ::recvfrom (fnum, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
+      &addrlen);
+  if (retlen < 0)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  p->setAddress (new ::java::net::InetAddress (raddr, NULL));
+  p->setPort (rport);
+  p->setLength ((jint) retlen);
+  return rport;
+
+ error:
+  char* strerr = strerror (errno);
+
+  if (errno == ECONNREFUSED)
+    throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+  // Avoid races from asynchronous finalization.
+  JvSynchronize sync (this);
+
+  // The method isn't declared to throw anything, so we disregard
+  // the return value.
+  _Jv_close (fnum);
+  fnum = -1;
+  timeout = 0;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  jint rport = p->getPort();
+  union SockAddr u;
+  jbyteArray haddress = p->getAddress()->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  jbyte *dbytes = elements (p->getData());
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+      memcpy (&u.address.sin_addr, bytes, len);
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (rport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (rport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
+    return;
+
+  char* strerr = strerror (errno);
+
+  if (errno == ECONNREFUSED)
+    throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyte *dbytes = elements (p->getData());
+  ssize_t retlen = 0;
+
+  // Do timeouts via select since SO_RCVTIMEO is not always available.
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
+    {
+      fd_set rset;
+      struct timeval tv;
+      FD_ZERO(&rset);
+      FD_SET(fnum, &rset);
+      tv.tv_sec = timeout / 1000;
+      tv.tv_usec = (timeout % 1000) * 1000;
+      int retval;
+      if ((retval = _Jv_select (fnum + 1, &rset, NULL, NULL, &tv)) < 0)
+        goto error;
+      else if (retval == 0)
+        throw new ::java::io::InterruptedIOException ();
+    }
+
+  retlen =
+    ::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
+      &addrlen);
+  if (retlen < 0)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  p->setAddress (new ::java::net::InetAddress (raddr, NULL));
+  p->setPort (rport);
+  p->setLength ((jint) retlen);
+  return;
+
+ error:
+  char* strerr = strerror (errno);
+
+  if (errno == ECONNREFUSED)
+    throw new ::java::net::PortUnreachableException (JvNewStringUTF (strerr));
+
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
+{
+  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+  char val = (char) ttl;
+  socklen_t val_len = sizeof(val);
+
+  if (::setsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
+    return;
+
+  char* strerr = strerror (errno);
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+  char val;
+  socklen_t val_len = sizeof(val);
+
+  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
+    return ((int) val) & 0xFF;
+
+  char* strerr = strerror (errno);
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *inetaddr,
+                                                   ::java::net::NetworkInterface *,
+                                                   jboolean join)
+{
+  // FIXME: implement use of NetworkInterface
+
+  union McastReq u;
+  jbyteArray haddress = inetaddr->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  int level, opname;
+  const char *ptr;
+  if (0)
+    ;
+#if HAVE_STRUCT_IP_MREQ
+  else if (len == 4)
+    {
+      level = IPPROTO_IP;
+      opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
+      memcpy (&u.mreq.imr_multiaddr, bytes, len);
+      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+      u.mreq.imr_interface.s_addr = htonl (INADDR_ANY); 
+      len = sizeof (struct ip_mreq);
+      ptr = (const char *) &u.mreq;
+    }
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+  else if (len == 16)
+    {
+      level = IPPROTO_IPV6;
+
+      /* Prefer new RFC 2553 names.  */
+#ifndef IPV6_JOIN_GROUP
+#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
+#endif
+#ifndef IPV6_LEAVE_GROUP
+#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
+#endif
+
+      opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
+      memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
+      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+      u.mreq6.ipv6mr_interface = 0;
+      len = sizeof (struct ipv6_mreq);
+      ptr = (const char *) &u.mreq6;
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::setsockopt (fnum, level, opname, ptr, len) == 0)
+    return;
+
+  char* strerr = strerror (errno);
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint optID,
+                                                    ::java::lang::Object *value)
+{
+  int val;
+  socklen_t val_len = sizeof (val);
+
+  if (fnum < 0)
+    throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+  if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+    {
+      ::java::lang::Boolean *boolobj = 
+        static_cast< ::java::lang::Boolean *> (value);
+      val = boolobj->booleanValue() ? 1 : 0;
+    }
+  else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+    {
+      ::java::lang::Integer *intobj = 
+        static_cast< ::java::lang::Integer *> (value);          
+      val = (int) intobj->intValue();
+    }
+  // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
+
+  switch (optID) 
+    {
+      case _Jv_TCP_NODELAY_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+        return;
+      case _Jv_SO_LINGER_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_LINGER not valid for UDP"));
+        return;
+      case _Jv_SO_KEEPALIVE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+        return;
+
+      case _Jv_SO_BROADCAST_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+                          val_len) != 0)
+          goto error;
+	break;
+	
+      case _Jv_SO_OOBINLINE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
+        break;
+	
+      case _Jv_SO_SNDBUF_ :
+      case _Jv_SO_RCVBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+	  goto error;    
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif 
+        return;
+      case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+	if (::setsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+	    val_len) != 0)
+	  goto error;
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif 
+	return;
+      case _Jv_SO_BINDADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_BINDADDR: read only option"));
+        return;
+      case _Jv_IP_MULTICAST_IF_ :
+	union InAddr u;
+        jbyteArray haddress;
+	jbyte *bytes;
+	int len;
+	int level, opname;
+	const char *ptr;
+
+	haddress = ((::java::net::InetAddress *) value)->addr;
+	bytes = elements (haddress);
+	len = haddress->length;
+	if (len == 4)
+	  {
+	    level = IPPROTO_IP;
+	    opname = IP_MULTICAST_IF;
+	    memcpy (&u.addr, bytes, len);
+	    len = sizeof (struct in_addr);
+	    ptr = (const char *) &u.addr;
+	  }
+// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
+	else if (len == 16)
+	  {
+	    level = IPPROTO_IPV6;
+	    opname = IPV6_MULTICAST_IF;
+	    memcpy (&u.addr6, bytes, len);
+	    len = sizeof (struct in6_addr);
+	    ptr = (const char *) &u.addr6;
+	  }
+#endif
+	else
+	  throw
+	    new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+	if (::setsockopt (fnum, level, opname, ptr, len) != 0)
+	  goto error;
+        return;
+	
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+        break;
+	
+      case _Jv_IP_MULTICAST_LOOP_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
+        break;
+	
+      case _Jv_IP_TOS_ :
+        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+	   val_len) != 0)
+	  goto error;    
+	return;
+	
+      case _Jv_SO_TIMEOUT_ :
+	timeout = val;
+        return;
+      default :
+        errno = ENOPROTOOPT;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint optID)
+{
+  int val;
+  socklen_t val_len = sizeof(val);
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+
+  switch (optID)
+    {
+      case _Jv_TCP_NODELAY_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+        break;
+      case _Jv_SO_LINGER_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_LINGER not valid for UDP"));
+        break;    
+      case _Jv_SO_KEEPALIVE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+        break;
+	
+      case _Jv_SO_BROADCAST_ :
+	if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+	    &val_len) != 0)
+	  goto error;
+	return new ::java::lang::Boolean (val != 0);
+	
+      case _Jv_SO_OOBINLINE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
+        break;
+      
+      case _Jv_SO_RCVBUF_ :
+      case _Jv_SO_SNDBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+	  goto error;    
+        else
+	  return new ::java::lang::Integer (val);
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif    
+	break;
+      case _Jv_SO_BINDADDR_:
+	// cache the local address
+	if (localAddress == NULL)
+	  {	
+	    jbyteArray laddr;
+	    if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
+	      goto error;
+	    if (u.address.sin_family == AF_INET)
+	      {
+		laddr = JvNewByteArray (4);
+		memcpy (elements (laddr), &u.address.sin_addr, 4);
+	      }
+#ifdef HAVE_INET6
+            else if (u.address.sin_family == AF_INET6)
+	      {
+		laddr = JvNewByteArray (16);
+		memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+	      }
+#endif
+	    else
+	      throw new ::java::net::SocketException (
+			      JvNewStringUTF ("invalid family"));
+	    localAddress = new ::java::net::InetAddress (laddr, NULL);
+	  }
+	return localAddress;  
+	break;
+      case _Jv_SO_REUSEADDR_ :
+#if defined(SO_REUSEADDR)
+	if (::getsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+	    &val_len) != 0)
+	  goto error;
+	return new ::java::lang::Boolean (val != 0);
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_REUSEADDR not supported"));
+#endif 
+	break;
+      case _Jv_IP_MULTICAST_IF_ :
+#ifdef HAVE_INET_NTOA
+	struct in_addr inaddr;
+  	socklen_t inaddr_len;
+	char *bytes;
+
+  	inaddr_len = sizeof(inaddr);
+	if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
+	    &inaddr_len) != 0)
+	  goto error;
+
+	bytes = inet_ntoa (inaddr);
+
+	return ::java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
+#else
+	throw new ::java::net::SocketException (
+	  JvNewStringUTF ("IP_MULTICAST_IF: not available - no inet_ntoa()"));
+#endif
+	break;
+      case _Jv_SO_TIMEOUT_ :
+	return new ::java::lang::Integer (timeout);
+	break;
+	
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+        break;
+	
+      case _Jv_IP_MULTICAST_LOOP_ :
+	if (::getsockopt (fnum, SOL_SOCKET, IP_MULTICAST_LOOP, (char *) &val,
+	    &val_len) != 0)
+	  goto error;
+	return new ::java::lang::Boolean (val != 0);
+	
+      case _Jv_IP_TOS_ :
+        if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+           &val_len) != 0)
+          goto error;
+        return new ::java::lang::Integer (val);
+	
+      default :
+	errno = ENOPROTOOPT;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
Index: gnu/java/net/natPlainDatagramSocketImplWin32.cc
===================================================================
RCS file: gnu/java/net/natPlainDatagramSocketImplWin32.cc
diff -N gnu/java/net/natPlainDatagramSocketImplWin32.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainDatagramSocketImplWin32.cc	6 Sep 2003 16:09:14 -0000
@@ -0,0 +1,704 @@
+/* Copyright (C) 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2
+#include <bstring.h>
+#endif
+
+#include <gnu/java/net/PlainDatagramSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/SocketException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/NetworkInterface.h>
+#include <java/net/DatagramPacket.h>
+#include <java/net/PortUnreachableException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Integer.h>
+
+union SockAddr
+{
+  struct sockaddr_in address;
+#ifdef HAVE_INET6
+  struct sockaddr_in6 address6;
+#endif
+};
+
+union McastReq
+{
+#if HAVE_STRUCT_IP_MREQ
+  struct ip_mreq mreq;
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+  struct ipv6_mreq mreq6;
+#endif
+};
+
+union InAddr
+{
+  struct in_addr addr;
+#ifdef HAVE_INET6
+  struct in6_addr addr6;
+#endif
+};
+
+// FIXME: routines here and/or in natPlainSocketImpl.cc could throw
+// NoRouteToHostException; also consider UnknownHostException, ConnectException.
+
+void
+gnu::java::net::PlainDatagramSocketImpl::create ()
+{
+  SOCKET sock = ::socket (AF_INET, SOCK_DGRAM, 0);
+
+  if (sock == INVALID_SOCKET)
+    {
+      _Jv_ThrowSocketException ();
+    }
+
+  _Jv_platform_close_on_exec (sock);
+
+  // We use fnum in place of fd here.  From leaving fd null we avoid
+  // the double close problem in FileDescriptor.finalize.
+  fnum = (int) sock;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::bind (jint lport,
+					  ::java::net::InetAddress *host)
+{
+  union SockAddr u;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  // FIXME: Use getaddrinfo() to get actual protocol instead of assuming ipv4.
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+
+      if (host != NULL)
+        memcpy (&u.address.sin_addr, bytes, len);
+      else
+        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (lport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (lport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::bind (fnum, ptr, len) == 0)
+    {
+      socklen_t addrlen = sizeof(u);
+
+      if (lport != 0)
+        localPort = lport;
+      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
+        localPort = ntohs (u.address.sin_port);
+      else
+        goto error;
+
+      /* Allow broadcast by default. */
+      int broadcast = 1;
+      if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &broadcast,
+                        sizeof (broadcast)) != 0)
+        goto error;
+
+      return;
+    }
+
+error:
+  DWORD dwErrorCode = WSAGetLastError ();
+  throw new ::java::net::BindException (_Jv_WinStrError (dwErrorCode));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::connect (::java::net::InetAddress *, jint)
+{ 
+  throw new ::java::lang::InternalError (JvNewStringLatin1 (
+      "PlainDatagramSocketImpl::connect: not implemented yet"));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::disconnect ()
+{
+  throw new ::java::lang::InternalError (JvNewStringLatin1 (
+      "PlainDatagramSocketImpl::disconnect: not implemented yet"));
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peek (::java::net::InetAddress *i)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  ssize_t retlen =
+    ::recvfrom (fnum, (char *) NULL, 0, MSG_PEEK, (sockaddr*) &u,
+      &addrlen);
+  if (retlen < 0)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  i->addr = raddr;
+  return rport;
+error:
+  DWORD dwErrorCode = WSAGetLastError ();
+  if (dwErrorCode == WSAECONNRESET)
+    throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+
+  _Jv_ThrowIOException ();
+  return -1;
+    // we should never get here
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::peekData(::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyte *dbytes = elements (p->getData());
+  ssize_t retlen = 0;
+
+  if (timeout > 0)
+    {
+      int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
+        (char*)&timeout, sizeof(timeout));
+      if (nRet != NO_ERROR)
+        goto error;
+    }
+
+  retlen =
+    ::recvfrom (fnum, (char *) dbytes, p->getLength(), MSG_PEEK, (sockaddr*) &u,
+      &addrlen);
+  if (retlen == SOCKET_ERROR)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  p->setAddress (new InetAddress (raddr, NULL));
+  p->setPort (rport);
+  p->setLength ((jint) retlen);
+  return rport;
+
+error:
+  DWORD dwErrorCode = WSAGetLastError ();
+  if (dwErrorCode == WSAECONNRESET)
+    throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+  else if (dwErrorCode == WSAETIMEDOUT)
+    throw new ::java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
+  else
+    _Jv_ThrowIOException ();
+
+  return -1;
+    // we should never get here
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainDatagramSocketImpl::close ()
+{
+  // Avoid races from asynchronous finalization.
+  JvSynchronize sync (this);
+
+  // The method isn't declared to throw anything, so we disregard
+  // the return value.
+  ::closesocket (fnum);
+  fnum = -1;
+  timeout = 0;
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::send (::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  jint rport = p->getPort();
+  union SockAddr u;
+  jbyteArray haddress = p->getAddress()->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  jbyte *dbytes = elements (p->getData());
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+      memcpy (&u.address.sin_addr, bytes, len);
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (rport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (rport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::sendto (fnum, (char *) dbytes, p->getLength(), 0, ptr, len) >= 0)
+    return;
+
+  DWORD dwErrorCode = WSAGetLastError ();
+  if (dwErrorCode == WSAECONNRESET)
+    throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+
+  _Jv_ThrowIOException ();
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::receive (::java::net::DatagramPacket *p)
+{
+  // FIXME: Deal with Multicast and if the socket is connected.
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyte *dbytes = elements (p->getData());
+  ssize_t retlen = 0;
+
+  if (timeout > 0)
+    {
+      // This implementation doesn't allow specifying an infinite
+      // timeout after specifying a finite one, but Sun's JDK 1.4.1
+      // didn't seem to allow this either....
+      int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
+        (char*)&timeout, sizeof(timeout));
+      if (nRet != NO_ERROR)
+        goto error;
+    }
+
+  retlen =
+    ::recvfrom (fnum, (char *) dbytes, p->getLength(), 0, (sockaddr*) &u,
+      &addrlen);
+  if (retlen < 0)
+    goto error;
+  // FIXME: Deal with Multicast addressing and if the socket is connected.
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  p->setAddress (new ::java::net::InetAddress (raddr, NULL));
+  p->setPort (rport);
+  p->setLength ((jint) retlen);
+  return;
+
+ error:
+  DWORD dwErrorCode = WSAGetLastError();
+  if (dwErrorCode == WSAECONNRESET)
+    throw new ::java::net::PortUnreachableException (_Jv_WinStrError (dwErrorCode));
+  else if (dwErrorCode == WSAETIMEDOUT)
+    throw new ::java::net::SocketTimeoutException (_Jv_WinStrError (dwErrorCode));
+  else
+    throw new ::java::io::IOException (_Jv_WinStrError (dwErrorCode));
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setTimeToLive (jint ttl)
+{
+  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+  char val = (char) ttl;
+  socklen_t val_len = sizeof(val);
+
+  if (::setsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, val_len) == 0)
+    return;
+
+  _Jv_ThrowIOException ();
+}
+
+jint
+gnu::java::net::PlainDatagramSocketImpl::getTimeToLive ()
+{
+  // Assumes IPPROTO_IP rather than IPPROTO_IPV6 since socket created is IPv4.
+  char val;
+  socklen_t val_len = sizeof(val);
+
+  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_TTL, &val, &val_len) == 0)
+    return ((int) val) & 0xFF;
+
+  _Jv_ThrowIOException ();
+
+  return -1;
+    // we should never get here
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::mcastGrp (::java::net::InetAddress *inetaddr,
+                                              ::java::net::NetworkInterface *,
+					      jboolean join)
+{
+  // FIXME: implement use of NetworkInterface
+  jbyteArray haddress = inetaddr->addr;
+  int len = haddress->length;
+  int level, opname;
+  const char *ptr;
+  if (0)
+    ;
+#if HAVE_STRUCT_IP_MREQ
+  else if (len == 4)
+    {
+      level = IPPROTO_IP;
+      opname = join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP;
+      memcpy (&u.mreq.imr_multiaddr, bytes, len);
+      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+      u.mreq.imr_interface.s_addr = htonl (INADDR_ANY);
+      len = sizeof (struct ip_mreq);
+      ptr = (const char *) &u.mreq;
+    }
+#endif
+#if HAVE_STRUCT_IPV6_MREQ
+  else if (len == 16)
+    {
+      level = IPPROTO_IPV6;
+
+      /* Prefer new RFC 2553 names.  */
+#ifndef IPV6_JOIN_GROUP
+#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
+#endif
+#ifndef IPV6_LEAVE_GROUP
+#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
+#endif
+
+      opname = join ? IPV6_JOIN_GROUP : IPV6_LEAVE_GROUP;
+      memcpy (&u.mreq6.ipv6mr_multiaddr, bytes, len);
+      // FIXME:  If a non-default interface is set, use it; see Stevens p. 501.
+      // Maybe not, see note in last paragraph at bottom of Stevens p. 497.
+      u.mreq6.ipv6mr_interface = 0;
+      len = sizeof (struct ipv6_mreq);
+      ptr = (const char *) &u.mreq6;
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::setsockopt (fnum, level, opname, ptr, len) == 0)
+    return;
+
+  _Jv_ThrowIOException ();
+}
+
+void
+gnu::java::net::PlainDatagramSocketImpl::setOption (jint optID,
+					       ::java::lang::Object *value)
+{
+  int val;
+  socklen_t val_len = sizeof (val);
+
+  if (fnum < 0)
+    throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+  if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+    {
+      ::java::lang::Boolean *boolobj = 
+        static_cast< ::java::lang::Boolean *> (value);
+      val = boolobj->booleanValue() ? 1 : 0;
+    }
+  else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+    {
+      ::java::lang::Integer *intobj = 
+        static_cast< ::java::lang::Integer *> (value);          
+      val = (int) intobj->intValue();
+    }
+  // Else assume value to be an InetAddress for use with IP_MULTICAST_IF.
+
+  switch (optID)
+    {
+      case _Jv_TCP_NODELAY_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+        return;
+      case _Jv_SO_LINGER_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_LINGER not valid for UDP"));
+        return;
+      case _Jv_SO_KEEPALIVE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+        return;
+
+      case _Jv_SO_BROADCAST_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+                          val_len) != 0)
+          goto error;
+  break;
+
+      case _Jv_SO_OOBINLINE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_OOBINLINE: not valid for UDP"));
+        break;
+
+      case _Jv_SO_SNDBUF_ :
+      case _Jv_SO_RCVBUF_ :
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+    goto error;
+        return;
+      case _Jv_SO_REUSEADDR_ :
+  if (::setsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+      val_len) != 0)
+    goto error;
+  return;
+      case _Jv_SO_BINDADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_BINDADDR: read only option"));
+        return;
+      case _Jv_IP_MULTICAST_IF_ :
+  union InAddr u;
+        jbyteArray haddress;
+  jbyte *bytes;
+  int len;
+  int level, opname;
+  const char *ptr;
+
+  haddress = ((::java::net::InetAddress *) value)->addr;
+  bytes = elements (haddress);
+  len = haddress->length;
+  if (len == 4)
+    {
+      level = IPPROTO_IP;
+      opname = IP_MULTICAST_IF;
+      memcpy (&u.addr, bytes, len);
+      len = sizeof (struct in_addr);
+      ptr = (const char *) &u.addr;
+    }
+// Tru64 UNIX V5.0 has struct sockaddr_in6, but no IPV6_MULTICAST_IF
+#if defined (HAVE_INET6) && defined (IPV6_MULTICAST_IF)
+  else if (len == 16)
+    {
+      level = IPPROTO_IPV6;
+      opname = IPV6_MULTICAST_IF;
+      memcpy (&u.addr6, bytes, len);
+      len = sizeof (struct in6_addr);
+      ptr = (const char *) &u.addr6;
+    }
+#endif
+  else
+    throw
+      new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (::setsockopt (fnum, level, opname, ptr, len) != 0)
+    goto error;
+        return;
+
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+        break;
+
+      case _Jv_IP_MULTICAST_LOOP_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_LOOP: not yet implemented"));
+        break;
+
+      case _Jv_IP_TOS_ :
+        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+     val_len) != 0)
+    goto error;
+  return;
+
+      case _Jv_SO_TIMEOUT_ :
+  timeout = val;
+        return;
+      default :
+        WSASetLastError (WSAENOPROTOOPT);
+    }
+
+ error:
+  _Jv_ThrowSocketException ();
+}
+
+::java::lang::Object *
+gnu::java::net::PlainDatagramSocketImpl::getOption (jint optID)
+{
+  int val;
+  socklen_t val_len = sizeof(val);
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+
+  switch (optID)
+    {
+      case _Jv_TCP_NODELAY_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("TCP_NODELAY not valid for UDP"));
+        break;
+      case _Jv_SO_LINGER_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_LINGER not valid for UDP"));
+        break;
+      case _Jv_SO_KEEPALIVE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_KEEPALIVE not valid for UDP"));
+        break;
+
+      case _Jv_SO_BROADCAST_ :
+  if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+      &val_len) != 0)
+    goto error;
+  return new ::java::lang::Boolean (val != 0);
+
+      case _Jv_SO_OOBINLINE_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_OOBINLINE not valid for UDP"));
+        break;
+
+      case _Jv_SO_RCVBUF_ :
+      case _Jv_SO_SNDBUF_ :
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+    goto error;
+        else
+    return new ::java::lang::Integer (val);
+  break;
+      case _Jv_SO_BINDADDR_:
+  // cache the local address
+  if (localAddress == NULL)
+    {
+      jbyteArray laddr;
+      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
+        goto error;
+      if (u.address.sin_family == AF_INET)
+        {
+    laddr = JvNewByteArray (4);
+    memcpy (elements (laddr), &u.address.sin_addr, 4);
+        }
+#ifdef HAVE_INET6
+            else if (u.address.sin_family == AF_INET6)
+        {
+    laddr = JvNewByteArray (16);
+    memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+        }
+#endif
+      else
+        throw new ::java::net::SocketException (
+            JvNewStringUTF ("invalid family"));
+      localAddress = new ::java::net::InetAddress (laddr, NULL);
+    }
+  return localAddress;
+  break;
+      case _Jv_SO_REUSEADDR_ :
+  if (::getsockopt (fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &val,
+      &val_len) != 0)
+    goto error;
+  return new ::java::lang::Boolean (val != 0);
+  break;
+      case _Jv_IP_MULTICAST_IF_ :
+  struct in_addr inaddr;
+    socklen_t inaddr_len;
+  char *bytes;
+
+    inaddr_len = sizeof(inaddr);
+  if (::getsockopt (fnum, IPPROTO_IP, IP_MULTICAST_IF, (char *) &inaddr,
+      &inaddr_len) != 0)
+    goto error;
+
+  bytes = inet_ntoa (inaddr);
+
+  return ::java::net::InetAddress::getByName (JvNewStringLatin1 (bytes));
+  break;
+      case _Jv_SO_TIMEOUT_ :
+	return new ::java::lang::Integer (timeout);
+	break;
+	
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not yet implemented"));
+        break;
+
+      case _Jv_IP_MULTICAST_LOOP_ :
+  if (::getsockopt (fnum, SOL_SOCKET, IP_MULTICAST_LOOP, (char *) &val,
+      &val_len) != 0)
+    goto error;
+  return new ::java::lang::Boolean (val != 0);
+
+      case _Jv_IP_TOS_ :
+        if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+           &val_len) != 0)
+          goto error;
+        return new ::java::lang::Integer (val);
+	
+      default :
+        WSASetLastError (WSAENOPROTOOPT);
+    }
+
+error:
+  _Jv_ThrowSocketException ();
+  return 0;
+    // we should never get here
+}
Index: gnu/java/net/natPlainSocketImplNoNet.cc
===================================================================
RCS file: gnu/java/net/natPlainSocketImplNoNet.cc
diff -N gnu/java/net/natPlainSocketImplNoNet.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainSocketImplNoNet.cc	6 Sep 2003 16:09:14 -0000
@@ -0,0 +1,128 @@
+/* Copyright (C) 2003 Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/SocketException.h>
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("SocketImpl.create: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *, jint)
+{
+  throw new ::java::net::BindException (
+    JvNewStringLatin1 ("SocketImpl.bind: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *, jint)
+{
+  throw new ::java::net::ConnectException (
+    JvNewStringLatin1 ("SocketImpl.connect: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("SocketImpl.listen: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *)
+{
+  throw new ::java::io::IOException (
+    JvNewStringLatin1 ("SocketImpl.accept: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint, ::java::lang::Object *)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.setOption: unimplemented"));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.getOption: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl::read(void)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.read: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::write(jint b)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.write: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData(jint data)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.sendUrgentData: unimplemented"));
+}
+
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.available: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::close(void)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.close: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.shutdownInput: unimplemented"));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+  throw new ::java::net::SocketException (
+    JvNewStringLatin1 ("SocketImpl.shutdownOutput: unimplemented"));
+}
Index: gnu/java/net/natPlainSocketImplPosix.cc
===================================================================
RCS file: gnu/java/net/natPlainSocketImplPosix.cc
diff -N gnu/java/net/natPlainSocketImplPosix.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainSocketImplPosix.cc	6 Sep 2003 16:09:14 -0000
@@ -0,0 +1,857 @@
+/* Copyright (C) 2003  Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#ifdef HAVE_SYS_IOCTL_H
+#define BSD_COMP /* Get FIONREAD on Solaris2. */
+#include <sys/ioctl.h>
+#endif
+
+// Pick up FIONREAD on Solaris 2.5.
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <errno.h>
+#include <string.h>
+
+#if HAVE_BSTRING_H
+// Needed for bzero, implicitly used by FD_ZERO on IRIX 5.2 
+#include <bstring.h>
+#endif
+
+#include <gcj/cni.h>
+#include <gcj/javaprims.h>
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/InetSocketAddress.h>
+#include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Class.h>
+#include <java/lang/Integer.h>
+#include <java/lang/Thread.h>
+#include <java/lang/NullPointerException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/IllegalArgumentException.h>
+
+union SockAddr
+{
+  struct sockaddr_in address;
+#ifdef HAVE_INET6
+  struct sockaddr_in6 address6;
+#endif
+};
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean stream)
+{
+  int sock = _Jv_socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
+
+  if (sock < 0)
+    {
+      char* strerr = strerror (errno);
+      throw new ::java::io::IOException (JvNewStringUTF (strerr));
+    }
+
+  _Jv_platform_close_on_exec (sock);
+
+  // We use fnum in place of fd here.  From leaving fd null we avoid
+  // the double close problem in FileDescriptor.finalize.
+  fnum = sock;
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *host, jint lport)
+{
+  union SockAddr u;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  int i = 1;
+
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+
+      if (host != NULL)
+        memcpy (&u.address.sin_addr, bytes, len);
+      else
+        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (lport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (lport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
+  ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
+  
+  if (_Jv_bind (fnum, ptr, len) == 0)
+    {
+      address = host;
+      socklen_t addrlen = sizeof(u);
+
+      if (lport != 0)
+        localport = lport;
+      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
+        localport = ntohs (u.address.sin_port);
+      else
+        goto error;
+
+      return;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::BindException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
+                                     jint timeout)
+{
+  ::java::net::InetSocketAddress *tmp = (::java::net::InetSocketAddress*) addr;
+  ::java::net::InetAddress *host = tmp->getAddress();
+  jint rport = tmp->getPort();
+	
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+      memcpy (&u.address.sin_addr, bytes, len);
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (rport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (rport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (timeout > 0)
+    {
+      int flags = ::fcntl (fnum, F_GETFL);
+      ::fcntl (fnum, F_SETFL, flags | O_NONBLOCK);
+      
+      if ((_Jv_connect (fnum, ptr, len) != 0) && (errno != EINPROGRESS))
+        goto error;
+
+      fd_set fset;
+      struct timeval tv;
+      FD_ZERO(&fset);
+      FD_SET(fnum, &fset);
+      tv.tv_sec = timeout / 1000;
+      tv.tv_usec = (timeout % 1000) * 1000;
+      int retval;
+      
+      if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
+        goto error;
+      else if (retval == 0)
+        throw new ::java::net::SocketTimeoutException
+          (JvNewStringUTF ("Connect timed out"));
+       // Set the socket back into a blocking state.
+       ::fcntl (fnum, F_SETFL, flags);
+    }
+  else
+    {
+      if (_Jv_connect (fnum, ptr, len) != 0)
+        goto error;
+    }
+
+  address = host;
+  port = rport;
+
+  // A bind may not have been done on this socket; if so, set localport now.
+  if (localport == 0)
+    {
+      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) == 0)
+        localport = ntohs (u.address.sin_port);
+      else
+        goto error;
+    }
+
+  return;  
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::ConnectException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint backlog)
+{
+  if (::listen (fnum, backlog) != 0)
+    {
+      char* strerr = strerror (errno);
+      throw new ::java::io::IOException (JvNewStringUTF (strerr));
+    }
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (gnu::java::net::PlainSocketImpl *s)
+{
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  int new_socket = 0; 
+
+  // Do timeouts via select since SO_RCVTIMEO is not always available.
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
+    {
+      fd_set fset;
+      struct timeval tv;
+      FD_ZERO(&fset);
+      FD_SET(fnum, &fset);
+      tv.tv_sec = timeout / 1000;
+      tv.tv_usec = (timeout % 1000) * 1000;
+      int retval;
+      if ((retval = _Jv_select (fnum + 1, &fset, &fset, NULL, &tv)) < 0)
+        goto error;
+      else if (retval == 0)
+        throw new ::java::net::SocketTimeoutException (
+	                                  JvNewStringUTF("Accept timed out"));
+    }
+
+  new_socket = _Jv_accept (fnum, (sockaddr*) &u, &addrlen);
+
+  if (new_socket < 0)
+    goto error;
+
+  _Jv_platform_close_on_exec (new_socket);
+
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  s->fnum = new_socket;
+  s->localport = localport;
+  s->address = new ::java::net::InetAddress (raddr, NULL);
+  s->port = rport;
+  return;
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::io::IOException (JvNewStringUTF (strerr));
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainSocketImpl::close()
+{
+  // Avoid races from asynchronous finalization.
+  JvSynchronize sync (this);
+
+  // should we use shutdown here? how would that effect so_linger?
+  int res = _Jv_close (fnum);
+
+  if (res == -1)
+    {
+      // These three errors are not errors according to tests performed
+      // on the reference implementation.
+      if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
+        throw new ::java::io::IOException  (JvNewStringUTF (strerror (errno)));
+    }
+  // Safe place to reset the file pointer.
+  fnum = -1;
+  timeout = 0;
+}
+
+// Write a byte to the socket.
+void
+gnu::java::net::PlainSocketImpl::write(jint b)
+{
+  jbyte d =(jbyte) b;
+  int r = 0;
+
+  while (r != 1)
+    {
+      r = _Jv_write (fnum, &d, 1);
+      if (r == -1)
+        {
+          if (::java::lang::Thread::interrupted())
+            {
+              ::java::io::InterruptedIOException *iioe
+                = new ::java::io::InterruptedIOException 
+                (JvNewStringLatin1 (strerror (errno)));
+              iioe->bytesTransferred = 0;
+              throw iioe;
+            }
+          // Some errors should not cause exceptions.
+          if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
+            throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+          break;
+        }
+    }
+}
+
+// Write some bytes to the socket.
+void
+gnu::java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
+{
+  if (! b)
+    throw new ::java::lang::NullPointerException;
+  if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
+    throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+  jbyte *bytes = elements (b) + offset;
+  int written = 0;
+
+  while (len > 0)
+    {
+      int r = _Jv_write (fnum, bytes, len);
+
+      if (r == -1)
+        {
+          if (::java::lang::Thread::interrupted())
+            {
+              ::java::io::InterruptedIOException *iioe
+                = new ::java::io::InterruptedIOException
+                (JvNewStringLatin1 (strerror (errno)));
+              iioe->bytesTransferred = written;
+              throw iioe;
+            }
+          // Some errors should not cause exceptions.
+          if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
+            throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+          break;
+        }
+
+      written += r;
+      len -= r;
+      bytes += r;
+    }
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData (jint)
+{
+  throw new ::java::net::SocketException (JvNewStringLatin1 (
+    "PlainSocketImpl: sending of urgent data not supported by this socket"));
+}
+
+// Read a single byte from the socket.
+jint
+gnu::java::net::PlainSocketImpl::read(void)
+{
+  jbyte b;
+
+  // Do timeouts via select.
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
+    {
+      // Create the file descriptor set.
+      fd_set read_fds;
+      FD_ZERO (&read_fds);
+      FD_SET (fnum,&read_fds);
+      // Create the timeout struct based on our internal timeout value.
+      struct timeval timeout_value;
+      timeout_value.tv_sec = timeout / 1000;
+      timeout_value.tv_usec = (timeout % 1000) * 1000;
+      // Select on the fds.
+      int sel_retval =
+        _Jv_select (fnum + 1, &read_fds, NULL, NULL, &timeout_value);
+      // If select returns 0 we've waited without getting data...
+      // that means we've timed out.
+      if (sel_retval == 0)
+        throw new ::java::net::SocketTimeoutException
+          (JvNewStringUTF ("read timed out") );
+      // If select returns ok we know we either got signalled or read some data...
+      // either way we need to try to read.
+    }
+
+  int r = _Jv_read (fnum, &b, 1);
+
+  if (r == 0)
+    return -1;
+
+  if (::java::lang::Thread::interrupted())
+    {
+      ::java::io::InterruptedIOException *iioe =
+        new ::java::io::InterruptedIOException
+        (JvNewStringUTF("read interrupted"));
+      iioe->bytesTransferred = r == -1 ? 0 : r;
+      throw iioe;
+    }
+  else if (r == -1)
+    {
+      // Some errors cause us to return end of stream...
+      if (errno == ENOTCONN)
+        return -1;
+
+      // Other errors need to be signalled.
+      throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+    }
+
+  return b & 0xFF;
+}
+
+// Read count bytes into the buffer, starting at offset.
+jint
+gnu::java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
+{
+  if (! buffer)
+    throw new ::java::lang::NullPointerException;
+
+  jsize bsize = JvGetArrayLength (buffer);
+
+  if (offset < 0 || count < 0 || offset + count > bsize)
+    throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+  jbyte *bytes = elements (buffer) + offset;
+
+  // Do timeouts via select.
+  if (timeout > 0 && fnum >= 0 && fnum < FD_SETSIZE)
+    {
+      // Create the file descriptor set.
+      fd_set read_fds;
+      FD_ZERO (&read_fds);
+      FD_SET (fnum, &read_fds);
+      // Create the timeout struct based on our internal timeout value.
+      struct timeval timeout_value;
+      timeout_value.tv_sec = timeout / 1000;
+      timeout_value.tv_usec =(timeout % 1000) * 1000;
+      // Select on the fds.
+      int sel_retval =
+        _Jv_select (fnum + 1, &read_fds, NULL, NULL, &timeout_value);
+      // We're only interested in the 0 return.
+      // error returns still require us to try to read 
+      // the socket to see what happened.
+      if (sel_retval == 0)
+        {
+          ::java::net::SocketTimeoutException *timeoutException =
+            new ::java::net::SocketTimeoutException
+            (JvNewStringUTF ("read timed out"));
+	  throw timeoutException;
+        }
+    }
+
+  // Read the socket.
+  int r = ::recv (fnum, (char *) bytes, count, 0);
+
+  if (r == 0)
+    return -1;
+
+  if (::java::lang::Thread::interrupted())
+    {
+      ::java::io::InterruptedIOException *iioe =
+        new ::java::io::InterruptedIOException
+        (JvNewStringUTF ("read interrupted"));
+      iioe->bytesTransferred = r == -1 ? 0 : r;
+      throw iioe;
+    }
+  else if (r == -1)
+    {
+      // Some errors cause us to return end of stream...
+      if (errno == ENOTCONN)
+        return -1;
+
+      // Other errors need to be signalled.
+      throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+    }
+
+  return r;
+}
+
+// How many bytes are available?
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+#if defined(FIONREAD) || defined(HAVE_SELECT)
+  long num = 0;
+  int r = 0;
+  bool num_set = false;
+
+#if defined(FIONREAD)
+  r = ::ioctl (fnum, FIONREAD, &num);
+
+  if (r == -1 && errno == ENOTTY)
+    {
+      // If the ioctl doesn't work, we don't care.
+      r = 0;
+      num = 0;
+    }
+  else
+    num_set = true;
+#elif defined(HAVE_SELECT)
+  if (fnum < 0)
+    {
+      errno = EBADF;
+      r = -1;
+    }
+#endif
+
+  if (r == -1)
+    {
+    posix_error:
+      throw new ::java::io::IOException(JvNewStringUTF(strerror(errno)));
+    }
+
+  // If we didn't get anything we can use select.
+
+#if defined(HAVE_SELECT)
+  if (! num_set)
+    if (! num_set && fnum >= 0 && fnum < FD_SETSIZE)
+      {
+        fd_set rd;
+        FD_ZERO (&rd);
+        FD_SET (fnum, &rd);
+        struct timeval tv;
+        tv.tv_sec = 0;
+        tv.tv_usec = 0;
+        r = _Jv_select (fnum + 1, &rd, NULL, NULL, &tv);
+        if(r == -1)
+          goto posix_error;
+        num = r == 0 ? 0 : 1;
+      }
+#endif /* HAVE_SELECT */
+
+  return (jint) num;
+#else
+  throw new ::java::io::IOException (JvNewStringUTF ("unimplemented"));
+#endif
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *value)
+{
+  int val;
+  socklen_t val_len = sizeof (val);
+
+  if (fnum < 0)
+    throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+  if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+    {
+      ::java::lang::Boolean *boolobj = 
+        static_cast< ::java::lang::Boolean *> (value);
+      if (boolobj->booleanValue())
+        val = 1; 
+      else 
+        {
+          if (optID == _Jv_SO_LINGER_)
+            val = -1;
+          else
+            val = 0;
+        }
+    }
+  else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+    {
+      ::java::lang::Integer *intobj = 
+        static_cast< ::java::lang::Integer *> (value);          
+      val = (int) intobj->intValue();
+    }
+  else
+    {
+      throw new ::java::lang::IllegalArgumentException (
+        JvNewStringLatin1 ("`value' must be Boolean or Integer"));
+    }
+
+  switch (optID) 
+    {
+      case _Jv_TCP_NODELAY_ :
+#ifdef TCP_NODELAY
+        if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+                          val_len) != 0)
+          goto error;
+#else
+        throw new ::java::lang::InternalError
+          (JvNewStringUTF ("TCP_NODELAY not supported"));
+#endif /* TCP_NODELAY */
+        return;
+
+      case _Jv_SO_KEEPALIVE_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+                          val_len) != 0)
+          goto error;
+        break;
+      
+      case _Jv_SO_BROADCAST_ :
+        throw new ::java::net::SocketException
+          (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
+        break;
+	
+      case _Jv_SO_OOBINLINE_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+                          val_len) != 0)
+          goto error;
+        break;
+
+      case _Jv_SO_LINGER_ :
+#ifdef SO_LINGER
+        struct linger l_val;
+        l_val.l_onoff = (val != -1);
+        l_val.l_linger = val;
+
+        if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+                          sizeof(l_val)) != 0)
+          goto error;    
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_LINGER not supported"));
+#endif /* SO_LINGER */
+        return;
+
+      case _Jv_SO_SNDBUF_ :
+      case _Jv_SO_RCVBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val, val_len) != 0)
+          goto error;    
+#else
+        throw new ::java::lang::InternalError (
+          JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif 
+        return;
+
+      case _Jv_SO_BINDADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_BINDADDR: read only option"));
+        return;
+
+      case _Jv_IP_MULTICAST_IF_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+        return;
+	
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+        break;
+	
+      case _Jv_IP_MULTICAST_LOOP_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+        break;
+	
+      case _Jv_IP_TOS_ :
+        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+                          val_len) != 0)
+          goto error;    
+        break;
+	
+      case _Jv_SO_REUSEADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+        return;
+
+      case _Jv_SO_TIMEOUT_ :
+        timeout = val;
+        return;
+
+      default :
+        errno = ENOPROTOOPT;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint optID)
+{
+  int val;
+  socklen_t val_len = sizeof(val);
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  struct linger l_val;
+  socklen_t l_val_len = sizeof(l_val);
+
+  switch (optID)
+    {
+#ifdef TCP_NODELAY
+    case _Jv_TCP_NODELAY_ :
+      if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+                        &val_len) != 0)
+        goto error;
+      else
+        return new ::java::lang::Boolean (val != 0);
+#else
+      throw new ::java::lang::InternalError
+        (JvNewStringUTF ("TCP_NODELAY not supported"));
+#endif       
+      break;
+      
+    case _Jv_SO_LINGER_ :
+#ifdef SO_LINGER
+      if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+                        &l_val_len) != 0)
+        goto error;    
+ 
+      if (l_val.l_onoff)
+        return new ::java::lang::Integer (l_val.l_linger);
+      else
+        return new ::java::lang::Boolean ((jboolean)false);
+#else
+      throw new ::java::lang::InternalError
+        (JvNewStringUTF ("SO_LINGER not supported"));
+#endif
+      break;    
+
+    case _Jv_SO_KEEPALIVE_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+                        &val_len) != 0)
+        goto error;
+      else
+        return new ::java::lang::Boolean (val != 0);
+
+    case _Jv_SO_BROADCAST_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+                        &val_len) != 0)
+        goto error;    
+      return new ::java::lang::Boolean ((jboolean)val);
+	
+    case _Jv_SO_OOBINLINE_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+                        &val_len) != 0)
+        goto error;    
+      return new ::java::lang::Boolean ((jboolean)val);
+	
+    case _Jv_SO_RCVBUF_ :
+    case _Jv_SO_SNDBUF_ :
+#if defined(SO_SNDBUF) && defined(SO_RCVBUF)
+      int opt;
+      optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+      if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val, &val_len) != 0)
+        goto error;    
+      else
+        return new ::java::lang::Integer (val);
+#else
+      throw new ::java::lang::InternalError
+        (JvNewStringUTF ("SO_RCVBUF/SO_SNDBUF not supported"));
+#endif    
+      break;
+    case _Jv_SO_BINDADDR_:
+      // cache the local address 
+      if (localAddress == NULL)
+        {
+          jbyteArray laddr;
+
+          if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != 0)
+            goto error;
+
+          if (u.address.sin_family == AF_INET)
+            {
+              laddr = JvNewByteArray (4);
+              memcpy (elements (laddr), &u.address.sin_addr, 4);
+            }
+#ifdef HAVE_INET6
+          else if (u.address.sin_family == AF_INET6)
+            {
+              laddr = JvNewByteArray (16);
+              memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+            }
+#endif
+          else
+            throw new ::java::net::SocketException
+              (JvNewStringUTF ("invalid family"));
+          localAddress = new ::java::net::InetAddress (laddr, NULL);
+        }
+
+      return localAddress;
+      break;
+    case _Jv_IP_MULTICAST_IF_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+      break;
+	
+    case _Jv_IP_MULTICAST_IF2_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+      break;
+	
+    case _Jv_IP_MULTICAST_LOOP_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+      break;
+	
+    case _Jv_IP_TOS_ :
+      if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+                        &val_len) != 0)
+        goto error;
+      return new ::java::lang::Integer (val);
+      break;
+	
+    case _Jv_SO_REUSEADDR_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+      break;
+
+    case _Jv_SO_TIMEOUT_ :
+      return new ::java::lang::Integer (timeout);
+      break;
+
+    default :
+      errno = ENOPROTOOPT;
+    }
+
+ error:
+  char* strerr = strerror (errno);
+  throw new ::java::net::SocketException (JvNewStringUTF (strerr));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+  if (::shutdown (fnum, 0))
+    throw new ::java::net::SocketException (JvNewStringUTF (strerror (errno)));
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+  if (::shutdown (fnum, 1))
+    throw new ::java::net::SocketException (JvNewStringUTF (strerror (errno)));
+}
Index: gnu/java/net/natPlainSocketImplWin32.cc
===================================================================
RCS file: gnu/java/net/natPlainSocketImplWin32.cc
diff -N gnu/java/net/natPlainSocketImplWin32.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/net/natPlainSocketImplWin32.cc	6 Sep 2003 16:09:14 -0000
@@ -0,0 +1,784 @@
+/* Copyright (C) 2003 Free Software Foundation
+
+   This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
+details.  */
+
+#include <config.h>
+#include <platform.h>
+
+#undef STRICT
+#undef MAX_PRIORITY
+#undef MIN_PRIORITY
+
+#include <gnu/java/net/PlainSocketImpl.h>
+#include <java/io/IOException.h>
+#include <java/io/InterruptedIOException.h>
+#include <java/net/BindException.h>
+#include <java/net/ConnectException.h>
+#include <java/net/InetAddress.h>
+#include <java/net/InetSocketAddress.h>
+#include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
+#include <java/lang/InternalError.h>
+#include <java/lang/Object.h>
+#include <java/lang/Boolean.h>
+#include <java/lang/Class.h>
+#include <java/lang/Integer.h>
+#include <java/lang/Thread.h>
+#include <java/lang/NullPointerException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/IllegalArgumentException.h>
+
+union SockAddr
+{
+  struct sockaddr_in address;
+#ifdef HAVE_INET6
+  struct sockaddr_in6 address6;
+#endif
+};
+
+void
+gnu::java::net::PlainSocketImpl::create (jboolean stream)
+{
+  int sock = ::socket (AF_INET, stream ? SOCK_STREAM : SOCK_DGRAM, 0);
+
+  if (sock == int(INVALID_SOCKET))
+    {
+      _Jv_ThrowIOException ();
+    }
+
+  _Jv_platform_close_on_exec (sock);
+
+  // We use fnum in place of fd here.  From leaving fd null we avoid
+  // the double close problem in FileDescriptor.finalize.
+  fnum = sock;
+}
+
+void
+gnu::java::net::PlainSocketImpl::bind (::java::net::InetAddress *host, jint lport)
+{
+  union SockAddr u;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  int i = 1;
+
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+
+      if (host != NULL)
+        memcpy (&u.address.sin_addr, bytes, len);
+      else
+        u.address.sin_addr.s_addr = htonl (INADDR_ANY);
+
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (lport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (lport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  // Enable SO_REUSEADDR, so that servers can reuse ports left in TIME_WAIT.
+  ::setsockopt(fnum, SOL_SOCKET, SO_REUSEADDR, (char *) &i, sizeof(i));
+
+  if (::bind (fnum, ptr, len) != SOCKET_ERROR)
+    {
+      address = host;
+      socklen_t addrlen = sizeof(u);
+
+      if (lport != 0)
+        localport = lport;
+      else if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
+        localport = ntohs (u.address.sin_port);
+      else
+        goto error;
+
+      return;
+    }
+
+error:
+  DWORD dwErrorCode = WSAGetLastError ();
+  throw new ::java::net::BindException (_Jv_WinStrError (dwErrorCode));
+}
+
+static void
+throwConnectException (DWORD dwErrorCode)
+{
+  throw new ::java::net::ConnectException (_Jv_WinStrError (dwErrorCode));
+}
+
+static void
+throwConnectException ()
+{
+  throwConnectException (WSAGetLastError ());
+}
+
+void
+gnu::java::net::PlainSocketImpl::connect (::java::net::SocketAddress *addr,
+                                     jint timeout)
+{
+  ::java::net::InetSocketAddress *tmp = (::java::net::InetSocketAddress*) addr;
+  ::java::net::InetAddress *host = tmp->getAddress();
+  jint rport = tmp->getPort();
+
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  jbyteArray haddress = host->addr;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;
+  struct sockaddr *ptr = (struct sockaddr *) &u.address;
+  
+  if (len == 4)
+    {
+      u.address.sin_family = AF_INET;
+      memcpy (&u.address.sin_addr, bytes, len);
+      len = sizeof (struct sockaddr_in);
+      u.address.sin_port = htons (rport);
+    }
+#ifdef HAVE_INET6
+  else if (len == 16)
+    {
+      u.address6.sin6_family = AF_INET6;
+      memcpy (&u.address6.sin6_addr, bytes, len);
+      len = sizeof (struct sockaddr_in6);
+      u.address6.sin6_port = htons (rport);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid length"));
+
+  if (timeout > 0)
+    {
+      // FIXME: we're creating a fresh WSAEVENT for each connect().
+      WSAEventWrapper aWSAEventWrapper(fnum, FD_CONNECT);
+      WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
+
+      if (::connect (fnum, ptr, len) == SOCKET_ERROR)
+      {
+        if (WSAGetLastError () != WSAEWOULDBLOCK)
+          throwConnectException ();
+
+        DWORD dwRet =
+          WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
+            // use true, false instead of TRUE, FALSE because the
+            // MS constants got undefined
+
+        if (dwRet == WSA_WAIT_FAILED)
+          throwConnectException ();
+        
+        else if (dwRet == WSA_WAIT_TIMEOUT)
+          throw new ::java::net::SocketTimeoutException
+            (JvNewStringUTF ("connect timed out"));
+            
+        // If we get here, we still need to check whether the actual
+        // connect() succeeded. Use any socket-specific error code
+        // instead of the thread-based one.
+        int nErrCode; int nErrLen=sizeof(nErrCode);
+        if (::getsockopt(fnum, SOL_SOCKET, SO_ERROR, (char*) &nErrCode,
+          &nErrLen) == SOCKET_ERROR)
+          {
+            throwConnectException ();
+          }
+        
+        if (nErrCode != NO_ERROR)
+          {
+            throwConnectException (nErrCode);
+          }
+      }
+    }
+  else
+    {
+      if (::connect (fnum, ptr, len) == SOCKET_ERROR)
+        throwConnectException();
+    }
+
+  address = host;
+  port = rport;
+
+  // A bind may not have been done on this socket; if so, set localport now.
+  if (localport == 0)
+    {
+      if (::getsockname (fnum, (sockaddr*) &u, &addrlen) != SOCKET_ERROR)
+        localport = ntohs (u.address.sin_port);
+      else
+        throwConnectException();
+    }
+}
+
+void
+gnu::java::net::PlainSocketImpl::listen (jint backlog)
+{
+  if (::listen (fnum, backlog) == SOCKET_ERROR)
+    {
+      _Jv_ThrowIOException ();
+    }
+}
+
+void
+gnu::java::net::PlainSocketImpl::accept (::java::net::PlainSocketImpl *s)
+{
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  int new_socket = 0;
+
+  if (timeout > 0)
+    {
+      // FIXME: we're creating a fresh WSAEVENT for each accept().
+      // One possible alternative would be that fnum really points
+      // to an extended structure consisting of the SOCKET, its
+      // associated WSAEVENT, etc.
+      WSAEventWrapper aWSAEventWrapper(fnum, FD_ACCEPT);
+      WSAEVENT hEvent = aWSAEventWrapper.getEventHandle ();
+
+      for (;;)
+      {
+        new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen);
+
+        if (new_socket != int(INVALID_SOCKET))
+        {
+          // This new child socket is nonblocking because the parent
+          // socket became nonblocking via the WSAEventSelect() call,
+          // so we set its mode back to blocking.
+          WSAEventSelect (new_socket, hEvent, 0);
+            // undo the hEvent <-> FD_ACCEPT association inherited
+            // inherited from our parent socket
+
+          unsigned long lSockOpt = 0L;
+            // blocking mode
+          if (ioctlsocket(new_socket, FIONBIO, &lSockOpt) == SOCKET_ERROR)
+          {
+            goto error;
+          }
+          break;
+        }
+        else if (WSAGetLastError () != WSAEWOULDBLOCK)
+          {
+            goto error;
+          }
+
+        DWORD dwRet =
+          WSAWaitForMultipleEvents (1, &hEvent, true, timeout, false);
+            // use true, false instead of TRUE, FALSE because the
+            // MS constants got undefined
+
+        if (dwRet == WSA_WAIT_FAILED)
+          goto error;
+        else if (dwRet == WSA_WAIT_TIMEOUT)
+          throw new ::java::net::SocketTimeoutException
+            (JvNewStringUTF ("accept timed out"));
+      }
+    }
+  else
+    {
+      new_socket = ::accept (fnum, (sockaddr*) &u, &addrlen);
+    }
+
+  if (new_socket == int(INVALID_SOCKET))
+    goto error;
+
+  _Jv_platform_close_on_exec (new_socket);
+
+  jbyteArray raddr;
+  jint rport;
+  if (u.address.sin_family == AF_INET)
+    {
+      raddr = JvNewByteArray (4);
+      memcpy (elements (raddr), &u.address.sin_addr, 4);
+      rport = ntohs (u.address.sin_port);
+    }
+#ifdef HAVE_INET6
+  else if (u.address.sin_family == AF_INET6)
+    {
+      raddr = JvNewByteArray (16);
+      memcpy (elements (raddr), &u.address6.sin6_addr, 16);
+      rport = ntohs (u.address6.sin6_port);
+    }
+#endif
+  else
+    throw new ::java::net::SocketException (JvNewStringUTF ("invalid family"));
+
+  s->fnum = new_socket;
+  s->localport = localport;
+  s->address = new InetAddress (raddr, NULL);
+  s->port = rport;
+  return;
+
+ error:
+  _Jv_ThrowIOException ();
+}
+
+// Close(shutdown) the socket.
+void
+gnu::java::net::PlainSocketImpl::close()
+{
+  // Avoid races from asynchronous finalization.
+  JvSynchronize sync (this);
+
+  // should we use shutdown here? how would that effect so_linger?
+  int res = ::closesocket (fnum);
+
+  if (res == -1)
+    {
+      // These three errors are not errors according to tests performed
+      // on the reference implementation.
+      DWORD dwErr = WSAGetLastError();
+      if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+        && dwErr != WSAENOTSOCK)
+        _Jv_ThrowIOException ();
+    }
+  // Safe place to reset the file pointer.
+  fnum = -1;
+  timeout = 0;
+}
+
+// Write a byte to the socket.
+void
+gnu::java::net::PlainSocketImpl::write(jint b)
+{
+  jbyte d =(jbyte) b;
+  int r = 0;
+
+  while (r != 1)
+    {
+      r = ::send (fnum, (char*) &d, 1, 0);
+      if (r == -1)
+        {
+          DWORD dwErr = WSAGetLastError();
+          if (::java::lang::Thread::interrupted())
+            {
+              ::java::io::InterruptedIOException *iioe
+                = new ::java::io::InterruptedIOException
+                (_Jv_WinStrError (dwErr));
+              iioe->bytesTransferred = 0;
+              throw iioe;
+            }
+          // Some errors should not cause exceptions.
+          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+            && dwErr != WSAENOTSOCK)
+            _Jv_ThrowIOException ();
+          break;
+        }
+    }
+}
+
+// Write some bytes to the socket.
+void
+gnu::java::net::PlainSocketImpl::write(jbyteArray b, jint offset, jint len)
+{
+  if (! b)
+    throw new ::java::lang::NullPointerException;
+  if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
+    throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+  jbyte *bytes = elements (b) + offset;
+  int written = 0;
+  while (len > 0)
+    {
+      int r = ::send (fnum, (char*) bytes, len, 0);
+
+      if (r == -1)
+        {
+          DWORD dwErr = WSAGetLastError();
+          if (::java::lang::Thread::interrupted())
+            {
+              ::java::io::InterruptedIOException *iioe
+                = new ::java::io::InterruptedIOException
+                (_Jv_WinStrError (dwErr));
+              iioe->bytesTransferred = written;
+              throw iioe;
+            }
+          // Some errors should not cause exceptions.
+          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
+            && dwErr != WSAENOTSOCK)
+            _Jv_ThrowIOException ();
+          break;
+        }
+
+      written += r;
+      len -= r;
+      bytes += r;
+    }
+}
+
+void
+gnu::java::net::PlainSocketImpl::sendUrgentData (jint)
+{
+  throw new ::java::net::SocketException (JvNewStringLatin1 (
+    "PlainSocketImpl: sending of urgent data not supported by this socket"));
+}
+
+// read() helper
+static jint
+doRead(int fnum, void* buf, int count, int timeout)
+{
+  int r = 0;
+  DWORD dwErrorCode = 0;
+    // we are forced to declare this here because
+    // a call to Thread::interrupted() blanks out
+    // WSAGetLastError().
+
+  // FIXME: we unconditionally set SO_RCVTIMEO here
+  // because we can't detect whether someone has
+  // gone from a non-zero to zero timeout. What we'd
+  // really need is a member state variable in addition
+  // to timeout
+  int nRet= ::setsockopt(fnum, SOL_SOCKET, SO_RCVTIMEO,
+    (char*)&timeout, sizeof(timeout));
+  if (nRet != NO_ERROR)
+  {
+    dwErrorCode = WSAGetLastError ();
+    goto error;
+  }
+  
+  r = ::recv (fnum, (char*) buf, count, 0);
+
+  if (r == 0)
+    return -1;
+
+  dwErrorCode = WSAGetLastError ();
+    // save WSAGetLastError() before calling Thread.interrupted()
+  
+  if (::java::lang::Thread::interrupted())
+    {
+      ::java::io::InterruptedIOException *iioe =
+        new ::java::io::InterruptedIOException
+        (JvNewStringUTF("read interrupted"));
+      iioe->bytesTransferred = r == -1 ? 0 : r;
+      throw iioe;
+    }
+  else if (r == -1)
+    {
+error:
+      // Some errors cause us to return end of stream...
+      if (dwErrorCode == WSAENOTCONN)
+        return -1;
+
+      // Other errors need to be signalled.
+      if (dwErrorCode == WSAETIMEDOUT)
+        throw new ::java::net::SocketTimeoutException
+          (JvNewStringUTF ("read timed out") );
+      else
+        _Jv_ThrowIOException (dwErrorCode);
+    }
+    
+   return r;
+}
+
+// Read a single byte from the socket.
+jint
+gnu::java::net::PlainSocketImpl::read(void)
+{
+  jbyte b;
+  doRead(fnum, &b, 1, timeout);
+  return b & 0xFF;
+}
+
+// Read count bytes into the buffer, starting at offset.
+jint
+gnu::java::net::PlainSocketImpl::read(jbyteArray buffer, jint offset, jint count)
+{
+  if (! buffer)
+    throw new ::java::lang::NullPointerException;
+
+  jsize bsize = JvGetArrayLength (buffer);
+
+  if (offset < 0 || count < 0 || offset + count > bsize)
+    throw new ::java::lang::ArrayIndexOutOfBoundsException;
+
+  jbyte *bytes = elements (buffer) + offset;
+
+  // Read the socket.
+  return doRead(fnum, bytes, count, timeout);
+}
+
+// How many bytes are available?
+jint
+gnu::java::net::PlainSocketImpl::available(void)
+{
+  unsigned long num = 0;
+
+  if (::ioctlsocket (fnum, FIONREAD, &num) == SOCKET_ERROR)
+    _Jv_ThrowIOException ();
+
+  return (jint) num;
+}
+
+void
+gnu::java::net::PlainSocketImpl::setOption (jint optID, ::java::lang::Object *value)
+{
+  int val;
+  socklen_t val_len = sizeof (val);
+
+  if (fnum < 0)
+    throw new ::java::net::SocketException (JvNewStringUTF ("Socket closed"));
+
+  if (_Jv_IsInstanceOf (value, &::java::lang::Boolean::class$))
+    {
+      ::java::lang::Boolean *boolobj =
+        static_cast< ::java::lang::Boolean *> (value);
+      if (boolobj->booleanValue())
+        val = 1;
+      else
+        {
+          if (optID == _Jv_SO_LINGER_)
+            val = -1;
+          else
+            val = 0;
+        }
+    }
+  else if (_Jv_IsInstanceOf (value, &::java::lang::Integer::class$))
+    {
+      ::java::lang::Integer *intobj =
+        static_cast< ::java::lang::Integer *> (value);
+      val = (int) intobj->intValue();
+    }
+  else
+    {
+      throw new ::java::lang::IllegalArgumentException (
+        JvNewStringLatin1 ("`value' must be Boolean or Integer"));
+    }
+
+  switch (optID)
+    {
+      case _Jv_TCP_NODELAY_ :
+        if (::setsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+                          val_len) == SOCKET_ERROR)
+          goto error;
+        return;
+
+      case _Jv_SO_KEEPALIVE_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+                          val_len) == SOCKET_ERROR)
+          goto error;
+        break;
+
+      case _Jv_SO_BROADCAST_ :
+        throw new ::java::net::SocketException
+          (JvNewStringUTF ("SO_BROADCAST not valid for TCP"));
+        break;
+
+      case _Jv_SO_OOBINLINE_ :
+        if (::setsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+                          val_len) == SOCKET_ERROR)
+          goto error;
+        break;
+
+      case _Jv_SO_LINGER_ :
+        struct linger l_val;
+        l_val.l_onoff = (val != -1);
+        l_val.l_linger = val;
+
+        if (::setsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+                          sizeof(l_val)) == SOCKET_ERROR)
+          goto error;
+        return;
+
+      case _Jv_SO_SNDBUF_ :
+      case _Jv_SO_RCVBUF_ :
+        int opt;
+        optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+        if (::setsockopt (fnum, SOL_SOCKET, opt, (char *) &val,
+                          val_len) == SOCKET_ERROR)
+          goto error;
+        return;
+
+      case _Jv_SO_BINDADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_BINDADDR: read only option"));
+        return;
+
+      case _Jv_IP_MULTICAST_IF_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+        return;
+
+      case _Jv_IP_MULTICAST_IF2_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+        break;
+
+      case _Jv_IP_MULTICAST_LOOP_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+        break;
+
+      case _Jv_IP_TOS_ :
+        if (::setsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+                          val_len) == SOCKET_ERROR)
+          goto error;
+        break;
+
+      case _Jv_SO_REUSEADDR_ :
+        throw new ::java::net::SocketException (
+          JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+        return;
+
+      case _Jv_SO_TIMEOUT_ :
+        timeout = val;
+        return;
+
+      default :
+        WSASetLastError (WSAENOPROTOOPT);
+    }
+
+error:
+  _Jv_ThrowSocketException ();
+}
+
+::java::lang::Object *
+gnu::java::net::PlainSocketImpl::getOption (jint optID)
+{
+  int val;
+  socklen_t val_len = sizeof(val);
+  union SockAddr u;
+  socklen_t addrlen = sizeof(u);
+  struct linger l_val;
+  socklen_t l_val_len = sizeof(l_val);
+
+  switch (optID)
+    {
+    case _Jv_TCP_NODELAY_ :
+      if (::getsockopt (fnum, IPPROTO_TCP, TCP_NODELAY, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      else
+        return new ::java::lang::Boolean (val != 0);
+      break;
+
+    case _Jv_SO_LINGER_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_LINGER, (char *) &l_val,
+                        &l_val_len) == SOCKET_ERROR)
+        goto error;
+
+      if (l_val.l_onoff)
+        return new ::java::lang::Integer (l_val.l_linger);
+      else
+        return new ::java::lang::Boolean ((jboolean)false);
+      break;
+
+    case _Jv_SO_KEEPALIVE_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_KEEPALIVE, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      else
+        return new ::java::lang::Boolean (val != 0);
+
+    case _Jv_SO_BROADCAST_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_BROADCAST, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      return new ::java::lang::Boolean ((jboolean)val);
+
+    case _Jv_SO_OOBINLINE_ :
+      if (::getsockopt (fnum, SOL_SOCKET, SO_OOBINLINE, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      return new ::java::lang::Boolean ((jboolean)val);
+
+    case _Jv_SO_RCVBUF_ :
+    case _Jv_SO_SNDBUF_ :
+      int opt;
+      optID == _Jv_SO_SNDBUF_ ? opt = SO_SNDBUF : opt = SO_RCVBUF;
+      if (::getsockopt (fnum, SOL_SOCKET, opt, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      else
+        return new ::java::lang::Integer (val);
+      break;
+    case _Jv_SO_BINDADDR_:
+      // cache the local address
+      if (localAddress == NULL)
+        {
+          jbyteArray laddr;
+
+          if (::getsockname (fnum, (sockaddr*) &u,
+                             &addrlen) == SOCKET_ERROR)
+            goto error;
+
+          if (u.address.sin_family == AF_INET)
+            {
+              laddr = JvNewByteArray (4);
+              memcpy (elements (laddr), &u.address.sin_addr, 4);
+            }
+#ifdef HAVE_INET6
+          else if (u.address.sin_family == AF_INET6)
+            {
+              laddr = JvNewByteArray (16);
+              memcpy (elements (laddr), &u.address6.sin6_addr, 16);
+            }
+#endif
+          else
+            throw new ::java::net::SocketException
+              (JvNewStringUTF ("invalid family"));
+          localAddress = new ::java::net::InetAddress (laddr, NULL);
+        }
+
+      return localAddress;
+      break;
+    case _Jv_IP_MULTICAST_IF_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_IF: not valid for TCP"));
+      break;
+
+    case _Jv_IP_MULTICAST_IF2_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_IF2: not valid for TCP"));
+      break;
+
+    case _Jv_IP_MULTICAST_LOOP_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("IP_MULTICAST_LOOP: not valid for TCP"));
+      break;
+
+    case _Jv_IP_TOS_ :
+      if (::getsockopt (fnum, SOL_SOCKET, IP_TOS, (char *) &val,
+                        &val_len) == SOCKET_ERROR)
+        goto error;
+      return new ::java::lang::Integer (val);
+      break;
+
+    case _Jv_SO_REUSEADDR_ :
+      throw new ::java::net::SocketException
+        (JvNewStringUTF ("SO_REUSEADDR: not valid for TCP"));
+      break;
+
+    case _Jv_SO_TIMEOUT_ :
+      return new ::java::lang::Integer (timeout);
+      break;
+
+    default :
+      WSASetLastError (WSAENOPROTOOPT);
+    }
+
+error:
+  _Jv_ThrowSocketException ();
+  return 0;
+    // we should never get here
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownInput (void)
+{
+  if (::shutdown (fnum, 0))
+    _Jv_ThrowSocketException ();
+}
+
+void
+gnu::java::net::PlainSocketImpl::shutdownOutput (void)
+{
+  if (::shutdown (fnum, 1))
+    _Jv_ThrowSocketException ();
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]