Skip to content

IPv6 支持有误 #15

@wsm25

Description

@wsm25

表现为 IPv6 端口并未被绑定,无法接收任何来自 IPv6 的请求。

应该是这里的问题:

let addrs: &[SocketAddr] = &[
SocketAddr::new(Ipv4Addr::UNSPECIFIED.into(), port),
SocketAddr::new(Ipv6Addr::UNSPECIFIED.into(), port),
];

let listener: Server = TcpListener::bind(addrs).await?.into();

按照 文档 的说法

If addr yields multiple addresses, bind will be attempted with each of the addresses until one succeeds and returns the listener. If none of the addresses succeed in creating a listener, the error returned from the last attempt (the last address) is returned.

因此事实上只绑定了 v4 端口而并未绑定 v6 端口。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions