From: Joel Reymont <joelr1@gmail.com>
To: OCaml List <caml-list@inria.fr>
Cc: Gerd Stolpmann <gerd@gerd-stolpmann.de>
Subject: Solved! (was Re: Mac OSX getsocketpair/getsockname and IPv6)
Date: Sat, 5 May 2007 16:16:07 +0100 [thread overview]
Message-ID: <6AC4F0FE-E2D1-4EDD-87A5-2FA3CBB0FBBE@gmail.com> (raw)
In-Reply-To: <CAC7EB04-5208-4A58-9BB7-7DF59903B015@gmail.com>
The culprit is in alloc_sockaddr [1].
adr->s_gen.sa_family is 0 which stands for AF_UNSPEC in my /usr/
include/sys/socket.h.
alloc_sockaddr does not handle this family type and throws EAFNOSUPPORT.
I'm inclined to think that ocamlnet should be fixed and not the OCaml
library, although it would be helpful if an error different from
EAFNOSUPPORT was used.
I would have been most helpful to have a stack trace on exception as
this would have allowed me to narrow down the source of the problem
in no time rather than going spelunking through ocamlnet and OCaml
networking libraries.
Thanks, Joel
[1] otherlibs/unix/socketaddr.c
value alloc_sockaddr(union sock_addr_union * adr /*in*/,
socklen_param_type adr_len, int close_on_error)
{
value res;
switch(adr->s_gen.sa_family) {
#ifndef _WIN32
case AF_UNIX:
{ value n = copy_string(adr->s_unix.sun_path);
Begin_root (n);
res = alloc_small(1, 0);
Field(res,0) = n;
End_roots();
break;
}
#endif
case AF_INET:
{ value a = alloc_inet_addr(&adr->s_inet.sin_addr);
Begin_root (a);
res = alloc_small(2, 1);
Field(res,0) = a;
Field(res,1) = Val_int(ntohs(adr->s_inet.sin_port));
End_roots();
break;
}
#ifdef HAS_IPV6
case AF_INET6:
{ value a = alloc_inet6_addr(&adr->s_inet6.sin6_addr);
Begin_root (a);
res = alloc_small(2, 1);
Field(res,0) = a;
Field(res,1) = Val_int(ntohs(adr->s_inet6.sin6_port));
End_roots();
break;
}
#endif
default:
if (close_on_error != -1) close (close_on_error);
unix_error(EAFNOSUPPORT, "", Nothing);
}
return res;
}
--
http://wagerlabs.com/
next prev parent reply other threads:[~2007-05-05 15:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-05 12:40 ocamlnet: EAFNOSUPPORT on Max OSX Joel Reymont
2007-05-05 12:50 ` Joel Reymont
2007-05-05 12:57 ` [Caml-list] " Richard Jones
2007-05-05 14:00 ` Joel Reymont
2007-05-05 13:53 ` Mac OSX getsocketpair/getsockname and IPv6 Joel Reymont
2007-05-05 14:13 ` Serious bug in the OCaml FFI? Joel Reymont
2007-05-05 14:56 ` [Caml-list] " Olivier Andrieu
2007-05-05 15:24 ` Joel Reymont
2007-05-05 14:31 ` Mac OSX getsocketpair/getsockname and IPv6 Joel Reymont
2007-05-05 15:16 ` Joel Reymont [this message]
2007-05-06 10:05 ` [Caml-list] Solved! (was Re: Mac OSX getsocketpair/getsockname and IPv6) Gerd Stolpmann
2007-05-28 17:08 ` Paul Snively
2007-05-05 14:46 ` Mac OSX getsocketpair/getsockname and IPv6 Joel Reymont
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6AC4F0FE-E2D1-4EDD-87A5-2FA3CBB0FBBE@gmail.com \
--to=joelr1@gmail.com \
--cc=caml-list@inria.fr \
--cc=gerd@gerd-stolpmann.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox