Browse thread
ocamlnet: EAFNOSUPPORT on Max OSX
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Joel Reymont <joelr1@g...> |
| Subject: | Serious bug in the OCaml FFI? |
I'm using 32-bit Mac OSX 10.4.9 Intel.
I inserted a print-out into my version of socketpair.c [1] and ran my
OCaml test script
#use "topfind";;
#require "unix";;
let x, y = Unix.socketpair Unix.PF_UNIX Unix.SOCK_STREAM 0;;
Unix.getpeername y;;
which resulted in
unix_socketpair: domain = 1, type = 1, proto = 0
Exception: Unix.Unix_error (Unix.EAFNOSUPPORT, "", "").
Back at the toplevel
# (Obj.magic Unix.PF_UNIX:int);;
- : int = 0
# (Obj.magic Unix.SOCK_STREAM:int);;
- : int = 0
Now, how exactly does 0 become 1 here? I have no idea but there are
two tables defined in otherlibs/unix/socket.c:
int socket_domain_table[] = {
PF_UNIX, PF_INET,
#if defined(HAS_IPV6)
PF_INET6
#elif defined(PF_UNDEF)
PF_UNDEF
#else
0
#endif
};
int socket_type_table[] = {
SOCK_STREAM, SOCK_DGRAM, SOCK_RAW, SOCK_SEQPACKET
};
As you can see, instead of calling socketpair with PF_UNIX and
SOCK_STREAM), Ocaml is calling it with PF_INET6 and SOCK_DGRAM instead.
This is obviously a major problem. Any suggestions on what may be
causing it and how to fix it?
Thanks, Joel
[1] otherlibs/unix/socketpair.c
CAMLprim value unix_socketpair(value domain, value type, value proto)
{
int sv[2];
value res;
printf("unix_socketpair: domain = %d, type = %d, proto = %d\n",
socket_domain_table[Int_val(domain)],
socket_type_table[Int_val(type)],
Int_val(proto));
if (socketpair(socket_domain_table[Int_val(domain)],
socket_type_table[Int_val(type)],
Int_val(proto), sv) == -1)
uerror("socketpair", Nothing);
res = alloc_small(2, 0);
Field(res,0) = Val_int(sv[0]);
Field(res,1) = Val_int(sv[1]);
return res;
}
--
http://wagerlabs.com/