diff --git a/configure.ac b/configure.ac
index 873c3c9..45d6602 100644
--- a/configure.ac
+++ b/configure.ac
@@ -161,6 +161,7 @@ AC_HEADER_STDBOOL
 AC_CHECK_HEADERS(unistd.h sys/time.h)
 AC_CHECK_HEADERS(termios.h sys/ioctl.h sys/select.h utime.h sys/utime.h)
 AC_CHECK_HEADERS(stdint.h inttypes.h pwd.h wchar.h)
+AC_CHECK_HEADERS(arpa/inet.h)
 
 AC_CHECK_DECLS(h_errno,,,[#include <netdb.h>])
 
diff --git a/m4/wget.m4 b/m4/wget.m4
index 02d0cf9..33825e2 100644
--- a/m4/wget.m4
+++ b/m4/wget.m4
@@ -88,6 +88,7 @@ AC_DEFUN([WGET_POSIX_CLOCK], [
 
 dnl Check whether we need to link with -lnsl and -lsocket, as is the
 dnl case on e.g. Solaris.
+dnl Haiku needs libnetwork
 
 AC_DEFUN([WGET_NSL_SOCKET], [
   dnl On Solaris, -lnsl is needed to use gethostbyname.  But checking
@@ -107,6 +108,8 @@ AC_DEFUN([WGET_NSL_SOCKET], [
     AC_CHECK_LIB(nsl, $wget_check_in_nsl)
   fi
   AC_CHECK_LIB(socket, socket)
+  AC_CHECK_LIB(network, gethostbyname)
+  AC_CHECK_LIB(network, socket)
 ])
 
 
diff --git a/src/config.h.in b/src/config.h.in
index 123560b..30a98f9 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -656,6 +656,9 @@
 /* Define to 1 if you have the <langinfo.h> header file. */
 #undef HAVE_LANGINFO_H
 
+/* Define to 1 if you have the `bind' library (-lbind). */
+#undef HAVE_LIBBIND
+
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL
 
@@ -668,6 +671,9 @@
 /* Define if you have the libgnutls library. */
 #undef HAVE_LIBGNUTLS
 
+/* Define to 1 if you have the `network' library (-lnetwork). */
+#undef HAVE_LIBNETWORK
+
 /* Define to 1 if you have the `gpg-error' library (-lgpg-error). */
 #undef HAVE_LIBGPG_ERROR
 
diff --git a/src/connect.c b/src/connect.c
index 119ccb7..7237484 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -46,7 +46,7 @@ as that of the covered work.  */
 #  include <netdb.h>
 # endif /* def __VMS [else] */
 # include <netinet/in.h>
-# ifndef __BEOS__
+# ifdef HAVE_ARPA_INET_H
 #  include <arpa/inet.h>
 # endif
 #endif /* not WINDOWS */
diff --git a/src/host.h b/src/host.h
index 3f27ea0..3cd3ed9 100644
--- a/src/host.h
+++ b/src/host.h
@@ -42,9 +42,9 @@ as that of the covered work.  */
 # endif /* def __VMS [else] */
 # include <sys/socket.h>
 # include <netinet/in.h>
-#ifndef __BEOS__
-# include <arpa/inet.h>
-#endif
+# ifdef HAVE_ARPA_INET_H
+#  include <arpa/inet.h>
+# endif
 #endif
 
 struct url;
-- 
1.8.3.4

