saulecabrera opened issue #12475:
Test Case
With the latest Wasmtime
devversion, the following test:async fn test_wrong_address_family(family: IpAddressFamily) { let sock = UdpSocket::create(family).unwrap(); let addr = match family { IpAddressFamily::Ipv4 => IpSocketAddress::localhost(IpAddressFamily::Ipv6, 0), IpAddressFamily::Ipv6 => IpSocketAddress::localhost(IpAddressFamily::Ipv4, 0), }; let result = sock.send(vec![0; 1], Some(addr)).await; assert!(matches!(result, Err(ErrorCode::InvalidArgument))); }Passes on macOS, but fails on Ubuntu/Windows.
According to the spec:
invalid-argumentshould be returned if theremote-addresshas the wrong address family. (EAFNOSUPPORT)
saulecabrera added the bug label to Issue #12475.
saulecabrera added the wasi label to Issue #12475.
saulecabrera edited issue #12475:
With the latest Wasmtime
devversion, the following test:async fn test_wrong_address_family(family: IpAddressFamily) { let sock = UdpSocket::create(family).unwrap(); let addr = match family { IpAddressFamily::Ipv4 => IpSocketAddress::localhost(IpAddressFamily::Ipv6, 0), IpAddressFamily::Ipv6 => IpSocketAddress::localhost(IpAddressFamily::Ipv4, 0), }; let result = sock.send(vec![0; 1], Some(addr)).await; assert!(matches!(result, Err(ErrorCode::InvalidArgument))); }Passes on macOS, but fails on Ubuntu/Windows.
According to the spec:
invalid-argumentshould be returned if theremote-addresshas the wrong address family. (EAFNOSUPPORT)
saulecabrera commented on issue #12475:
For completeness, this is the error on Ubuntu:
[src/bin/sockets-udp-send.rs:21:5] &result = Err( ErrorCode { code: 2, name: "not-supported", message: "The operation is not supported.\n\n POSIX equivalent: EOPNOTSUPP", }, )
alexcrichton commented on issue #12475:
Should this perhaps be a case where the spec is changed to allow more error codes for this situation? I never quite know how to best thread the needle but translating a native
EAFNOSUPPORTtonot-supportedhere doesn't seem entirely unreasonable to me
bjorn3 commented on issue #12475:
I believe on macOS an ipv6 socket can actually connect to ipv4 addresses (and by default listening on an ipv6 socket will also listen on ipv4) The IPV6_V6ONLY option disables this behavior.
Last updated: Feb 24 2026 at 04:36 UTC