AC_DEFUN(DAST_ACCEPT_ARG, [
  if test -z "$ac_cv_accept_arg" ; then
    AC_LANG_SAVE
    AC_LANG_CPLUSPLUS

    AC_TRY_COMPILE(
      [#include <sys/types.h>
       #include <sys/socket.h>],
      [$1 length;
       accept( 0, 0, &length );],
    ac_cv_accept_arg=$1,
    ac_cv_accept_arg=)

    AC_LANG_RESTORE
  fi
])

AC_CACHE_CHECK(3rd argument of accept, ac_cv_accept_arg, [
  dnl Try socklen_t (POSIX)
  DAST_ACCEPT_ARG(socklen_t)

  dnl Try int (original BSD)
  DAST_ACCEPT_ARG(int)

  dnl Try size_t (older standard; AIX)
  DAST_ACCEPT_ARG(size_t)

  dnl Try short (shouldn't be)
  DAST_ACCEPT_ARG(short)

  dnl Try long (shouldn't be)
  DAST_ACCEPT_ARG(long)
])

dnl Try asking the user
if test -z "$ac_cv_accept_arg" ; then
  DAST_ASK("What type is the 3rd argument of accept a pointer to?",
           ac_cv_accept_arg, int)
fi

AC_DEFINE_UNQUOTED(Socklen_t, $ac_cv_accept_arg)






