diff --git a/lib_eio_posix/test/test_await.ml b/lib_eio_posix/test/test_await.ml index d5533e63..6832636c 100644 --- a/lib_eio_posix/test/test_await.ml +++ b/lib_eio_posix/test/test_await.ml @@ -1,5 +1,12 @@ open Eio.Std +let () = + Eio_posix.run @@ fun env -> + Eio.Net.getaddrinfo_stream env#net "127.0.0.1" ~service:"7000" + |> List.iter (traceln "Got: %a" Eio.Net.Sockaddr.pp); + traceln "getaddrinfo: %d" (List.length (Unix.getaddrinfo "127.0.0.1" "7000" [])); + traceln "gethostbyname: %d" (Array.length ((Unix.gethostbyname "127.0.0.1").h_addr_list)) + let () = Eio_posix.run @@ fun _ -> let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in diff --git a/lib_eio_windows/net.ml b/lib_eio_windows/net.ml index cf3095ca..70f8eb3c 100755 --- a/lib_eio_windows/net.ml +++ b/lib_eio_windows/net.ml @@ -86,10 +86,12 @@ let datagram_socket fd = (* https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml *) let getaddrinfo ~service node = let to_eio_sockaddr_t {Unix.ai_family; ai_addr; ai_socktype; ai_protocol; _ } = + Fmt.epr "to_eio_sockaddr_t: ai_protocol=%d@." ai_protocol; match ai_family, ai_socktype, ai_addr with | (Unix.PF_INET | PF_INET6), (Unix.SOCK_STREAM | SOCK_DGRAM), Unix.ADDR_INET (inet_addr,port) -> ( + Fmt.epr "to_eio_sockaddr_t: ADDR_INET@."; match ai_protocol with | 6 -> Some (`Tcp (Eio_unix.Net.Ipaddr.of_unix inet_addr, port)) | 17 -> Some (`Udp (Eio_unix.Net.Ipaddr.of_unix inet_addr, port)) diff --git a/lib_eio_windows/test/test_net.ml b/lib_eio_windows/test/test_net.ml index c7ad5893..5949d6c0 100755 --- a/lib_eio_windows/test/test_net.ml +++ b/lib_eio_windows/test/test_net.ml @@ -105,6 +105,13 @@ let test_eio_socketpair () = let msg = Eio.Buf_read.of_flow b ~max_size:10 |> Eio.Buf_read.take_all in Alcotest.(check string) "same messagw" "foo" msg +let test_getaddrinfo env () = + Eio.Net.getaddrinfo_stream env#net "127.0.0.1" ~service:"7000" + |> List.iter (traceln "Got: %a" Eio.Net.Sockaddr.pp); + traceln "getaddrinfo: %d" (List.length (Unix.getaddrinfo "127.0.0.1" "7000" [])); + traceln "gethostbyname: %d" (Array.length ((Unix.gethostbyname "127.0.0.1").h_addr_list)); + assert false + let tests env = [ "tcp-ip4", `Quick, test_client_server env (`Tcp (Eio.Net.Ipaddr.V4.loopback, 8081)); "tcp-ip6", `Quick, test_client_server env (`Tcp (Eio.Net.Ipaddr.V6.loopback, 8081)); @@ -114,5 +121,6 @@ let tests env = [ "fds", `Quick, test_fd env Eio.Net.Ipaddr.V4.loopback; "wrap-pipe", `Quick, test_wrap_socket `Pipe; "wrap-socketpair", `Quick, test_wrap_socket `Socketpair; - "eio-socketpair", `Quick, test_eio_socketpair + "eio-socketpair", `Quick, test_eio_socketpair; + "getaddrinfo", `Quick, test_getaddrinfo env; ]