Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
IPv6 support under Windows #5676
Original bug ID: 5676
This patch (against trunk) adds IPv6 support under Windows.
Windows XP is required for compiling OCaml with IPv6 support. Compiled programs should work with older versions of Windows as well.
There are a lot of include order changes, as winsock2.h needs to be included before winsock.h.
The getnameinfo and getaddrinfo bindings are taken from the unix/ directory.
string_of_inet_addr and inet_addr_of_string are implemented using getnameinfo and getaddrinfo, as functions inet_pton and inet_ntop are only available in very recent versions of Windows.
Finally, the check for PF_INET6 in file socket.c is disabled. (By the way, the comment seems incorrect, as OCaml is already linked against Winsock 2.)
Comment author: @protz
Disclaimer: I'm not a Unix system programming guru, esp. under Windows, so please bear with me, but, I just gave this patch a try and it doesn't seem to work fully.
let a = inet_addr_of_string "2001:6b0:5:1688::200";;
val a : Unix.inet_addr =
let a = ADDR_INET (a, 8001);;
val a : Unix.sockaddr = ADDR_INET (, 8001)
let ic, oc = open_connection a;;
Exception: Unix.Unix_error (EAFNOSUPPORT, "connect", "").
Is that expected?
Comment author: @protz
So I gave your patch a try and everything seems to compile/work fine as far as my light testing could tell.
Here's a few remarks on the patch:
Apart from that, the patch looks very good!
Comment author: vouillon
I'm only using "#if defined()" in win32unix/socket.c, and that's
"unixsupport.h" used to include <winsock.h>, and I've changed it
An alternative would have been to remove the inclusion of
Another alternative would be to move the inclusion of <windows.h> to
In "winworker.h", <winsock2.h> needs to be included between
So, I have moved the inclusion of "unixsupport.h" there and
There were some missing includes, including this one. Indeed,
Here, times.c uses function alloc_small which is declared in <alloc.h>.
A set_close_on_exec was added in unix/unix.ml in revision 6420
It seems more coherent to have it as well under Windows.
Do you want separate patches for the additional includes (such as