diff --git a/Network.hs b/Network.hs
--- a/Network.hs
+++ b/Network.hs
@@ -257,7 +257,7 @@
 				-- the 'PortNumber' of the remote connection.
 accept sock@(MkSocket _ AF_INET _ _ _) = do
  ~(sock', (SockAddrInet port haddr)) <- Socket.accept sock
- peer <- Exception.catchJust Exception.ioErrors
+ peer <- catchIO
 	  (do 	
 	     (HostEntry peer _ _ _) <- getHostByAddr AF_INET haddr
 	     return peer
@@ -375,7 +375,7 @@
 -- ---------------------------------------------------------------------------
 -- Utils
 
-#if __GLASGOW_HASKELL__ < 606
+#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 606
 -- Like bracket, but only performs the final action if there was an 
 -- exception raised by the middle bit.
 bracketOnError
@@ -429,3 +429,11 @@
 >  import Posix
 >  main = do installHandler sigPIPE Ignore Nothing; ...
 -}
+
+catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
+#ifdef BASE4
+catchIO = Exception.catch
+#else
+catchIO = Exception.catchJust Exception.ioErrors
+#endif
+
diff --git a/Network/Socket.hsc b/Network/Socket.hsc
--- a/Network/Socket.hsc
+++ b/Network/Socket.hsc
@@ -501,7 +501,7 @@
 #if defined(darwin_TARGET_OS)
 	zeroMemory p (#const sizeof(struct sockaddr_un))
 #endif
-#if defined(netbsd_TARGET_OS)
+#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
 	(#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8)
 #endif
 	(#poke struct sockaddr_un, sun_family) p ((#const AF_UNIX) :: CSaFamily)
@@ -513,7 +513,7 @@
 #if defined(darwin_TARGET_OS)
 	zeroMemory p (#const sizeof(struct sockaddr_in))
 #endif
-#if defined(netbsd_TARGET_OS)
+#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
 	(#poke struct sockaddr_in, sin_len) p ((#const sizeof(struct sockaddr_in)) :: Word8)
 #endif
 	(#poke struct sockaddr_in, sin_family) p ((#const AF_INET) :: CSaFamily)
@@ -524,7 +524,7 @@
 #if defined(darwin_TARGET_OS)
 	zeroMemory p (#const sizeof(struct sockaddr_in6))
 #endif
-#if defined(netbsd_TARGET_OS)
+#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
 	(#poke struct sockaddr_in6, sin6_len) p ((#const sizeof(struct sockaddr_in6)) :: Word8)
 #endif
 	(#poke struct sockaddr_in6, sin6_family) p ((#const AF_INET6) :: CSaFamily)
diff --git a/Network/URI.hs b/Network/URI.hs
--- a/Network/URI.hs
+++ b/Network/URI.hs
@@ -125,7 +125,11 @@
 
 #ifdef __GLASGOW_HASKELL__
 import Data.Typeable  ( Typeable )
+#ifdef BASE4
+import Data.Data      ( Data )
+#else
 import Data.Generics  ( Data )
+#endif
 #else
 import Data.Typeable  ( Typeable(..), TyCon, mkTyCon, mkTyConApp )
 #endif
diff --git a/configure b/configure
--- a/configure
+++ b/configure
@@ -4133,6 +4133,121 @@
 fi
 
 
+{ echo "$as_me:$LINENO: checking for struct sockaddr.sa_len" >&5
+echo $ECHO_N "checking for struct sockaddr.sa_len... $ECHO_C" >&6; }
+if test "${ac_cv_member_struct_sockaddr_sa_len+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+int
+main ()
+{
+static struct sockaddr ac_aggr;
+if (ac_aggr.sa_len)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_sockaddr_sa_len=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+
+int
+main ()
+{
+static struct sockaddr ac_aggr;
+if (sizeof ac_aggr.sa_len)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_member_struct_sockaddr_sa_len=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_member_struct_sockaddr_sa_len=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_member_struct_sockaddr_sa_len" >&5
+echo "${ECHO_T}$ac_cv_member_struct_sockaddr_sa_len" >&6; }
+if test $ac_cv_member_struct_sockaddr_sa_len = yes; then
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_SOCKADDR_SA_LEN 1
+_ACEOF
+
+
+fi
+
+
 { echo "$as_me:$LINENO: checking for in_addr_t in netinet/in.h" >&5
 echo $ECHO_N "checking for in_addr_t in netinet/in.h... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -31,6 +31,14 @@
 # include <sys/uio.h>
 #endif])
 
+dnl ** check if struct sockaddr contains sa_len
+AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif])
+
 dnl --------------------------------------------------
 dnl * test for in_addr_t
 dnl --------------------------------------------------
diff --git a/include/HsNetworkConfig.h b/include/HsNetworkConfig.h
--- a/include/HsNetworkConfig.h
+++ b/include/HsNetworkConfig.h
@@ -0,0 +1,129 @@
+/* include/HsNetworkConfig.h.  Generated from HsNetworkConfig.h.in by configure.  */
+/* include/HsNetworkConfig.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#define HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have a BSDish sendfile(2) implementation. */
+/* #undef HAVE_BSD_SENDFILE */
+
+/* Define to 1 if you have the declaration of `AI_ADDRCONFIG', and to 0 if you
+   don't. */
+#define HAVE_DECL_AI_ADDRCONFIG 1
+
+/* Define to 1 if you have the declaration of `AI_ALL', and to 0 if you don't.
+   */
+#define HAVE_DECL_AI_ALL 1
+
+/* Define to 1 if you have the declaration of `AI_NUMERICSERV', and to 0 if
+   you don't. */
+#define HAVE_DECL_AI_NUMERICSERV 1
+
+/* Define to 1 if you have the declaration of `AI_V4MAPPED', and to 0 if you
+   don't. */
+#define HAVE_DECL_AI_V4MAPPED 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#define HAVE_FCNTL_H 1
+
+/* Define to 1 if you have the `getaddrinfo' function. */
+#define HAVE_GETADDRINFO 1
+
+/* Define to 1 if you have the `gethostent' function. */
+#define HAVE_GETHOSTENT 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if in_addr_t is available. */
+#define HAVE_IN_ADDR_T 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have a Linux sendfile(2) implementation. */
+#define HAVE_LINUX_SENDFILE 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#define HAVE_NETDB_H 1
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#define HAVE_NETINET_IN_H 1
+
+/* Define to 1 if you have the <netinet/tcp.h> header file. */
+#define HAVE_NETINET_TCP_H 1
+
+/* Define to 1 if you have the `readlink' function. */
+#define HAVE_READLINK 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if `msg_accrights' is member of `struct msghdr'. */
+/* #undef HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */
+
+/* Define to 1 if `msg_control' is member of `struct msghdr'. */
+#define HAVE_STRUCT_MSGHDR_MSG_CONTROL 1
+
+/* Define to 1 if `sa_len' is member of `struct sockaddr'. */
+/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */
+
+/* Define to 1 if you have both SO_PEERCRED and struct ucred. */
+#define HAVE_STRUCT_UCRED 1
+
+/* Define to 1 if you have the `symlink' function. */
+#define HAVE_SYMLINK 1
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#define HAVE_SYS_SOCKET_H 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#define HAVE_SYS_UIO_H 1
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#define HAVE_SYS_UN_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the <winsock.h> header file. */
+/* #undef HAVE_WINSOCK_H */
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "libraries@haskell.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "Haskell network package"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "Haskell network package 1.0"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "network"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "1.0"
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
diff --git a/include/HsNetworkConfig.h.in b/include/HsNetworkConfig.h.in
--- a/include/HsNetworkConfig.h.in
+++ b/include/HsNetworkConfig.h.in
@@ -76,6 +76,9 @@
 /* Define to 1 if `msg_control' is member of `struct msghdr'. */
 #undef HAVE_STRUCT_MSGHDR_MSG_CONTROL
 
+/* Define to 1 if `sa_len' is member of `struct sockaddr'. */
+#undef HAVE_STRUCT_SOCKADDR_SA_LEN
+
 /* Define to 1 if you have both SO_PEERCRED and struct ucred. */
 #undef HAVE_STRUCT_UCRED
 
diff --git a/network.cabal b/network.cabal
--- a/network.cabal
+++ b/network.cabal
@@ -1,27 +1,40 @@
-name:		network
-version:	2.2.0.0
-license:	BSD3
-license-file:	LICENSE
-maintainer:	libraries@haskell.org
-synopsis:	Networking-related facilities
+name:           network
+version:        2.2.0.1
+license:        BSD3
+license-file:   LICENSE
+maintainer:     libraries@haskell.org
+synopsis:       Networking-related facilities
+category:       System
 build-type:     Configure
-exposed-modules:
-		Network Network.BSD Network.Socket Network.URI
-extra-source-files:
-		config.guess config.sub install-sh
-		configure.ac configure
-		network.buildinfo.in include/HsNetworkConfig.h.in
-		include/HsNet.h include/Typeable.h
-		-- C sources only used on some systems
-		cbits/ancilData.c
-		cbits/asyncAccept.c cbits/initWinSock.c cbits/winSockErr.c
+cabal-version:  >=1.2
 extra-tmp-files:
-		config.log config.status autom4te.cache
-		network.buildinfo include/HsNetworkConfig.h
-build-depends:	base, parsec
-extensions:	CPP
-include-dirs: 	include
-includes:       HsNet.h
-install-includes:
-		HsNet.h HsNetworkConfig.h
-c-sources:	cbits/HsNet.c
+                config.log config.status autom4te.cache
+                network.buildinfo include/HsNetworkConfig.h
+extra-source-files:
+                config.guess config.sub install-sh
+                configure.ac configure
+                network.buildinfo.in include/HsNetworkConfig.h.in
+                include/HsNet.h include/Typeable.h
+                -- C sources only used on some systems
+                cbits/ancilData.c
+                cbits/asyncAccept.c cbits/initWinSock.c cbits/winSockErr.c
+
+flag base4
+
+library
+  exposed-modules:
+                Network Network.BSD Network.Socket Network.URI
+  build-depends: base < 5, parsec
+
+  if flag(base4)
+      build-depends:    base>=4
+      cpp-options:      -DBASE4
+  else
+      build-depends:    base<4
+
+  extensions:   CPP
+  include-dirs:         include
+  includes:       HsNet.h
+  install-includes:
+                HsNet.h HsNetworkConfig.h
+  c-sources:    cbits/HsNet.c
