AC_MSG_ERROR(cannot find socket)))
 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
 
+with_libxnet="no"
+AC_CHECK_LIB(xnet, __xnet_recvmsg, [with_libxnet="yes"],[])
+if test "x$with_libxnet" = "xyes"
+then
+       CFLAGS="$CFLAGS -D_XPG4_2 -D__EXTENSIONS__"
+fi
+AM_CONDITIONAL(BUILD_WITH_LIBXNET, test "x$with_libxnet" = "xyes")
+
 nanosleep_needs_rt="no"
 AC_CHECK_FUNCS(nanosleep, [],
        AC_CHECK_LIB(rt, nanosleep,
 
        msghdr.msg_controllen = sizeof (control_buffer);
        /* flags; this is an output only field.. */
        msghdr.msg_flags = 0;
+#ifdef MSG_XPG4_2
+       msghdr.msg_flags |= MSG_XPG4_2;
+#endif
 
        payload_buffer_len = recvmsg (fd, &msghdr, /* flags = */ 0);
        if (payload_buffer_len < 0)