Skip to content

Why listening "::" (all IPv6) also get "0.0.0.0"(all IPv4) listened? #9390

Closed
@jjqq2013

Description

@jjqq2013
  • Version:v7.0.0
  • Platform:Windows 7 Pro
  • Subsystem:

I found a strange problem, i created a simple TCP server to listen at port 5555 of "::"(all IPv6 interfaces)

net.createServer(c=>console.log).listen(5555,'::')

Then i found all IPv4 interfaces are also listening port 5555.

> netstat -an | findstr /I :5555
  TCP    0.0.0.0:5555           0.0.0.0:0              LISTENING
  TCP    [::]:5555              [::]:0                 LISTENING

Another relevant problem is, if i do not specify host, or use undefined, or empty string,

net.createServer(c=>console.log).listen(5555)
//or net.createServer(c=>console.log).listen(5555,undefined)
//or net.createServer(c=>console.log).listen(5555,'')

It should listen :: OR 0.0.0.0, not both, according the document:

server.listen([port][, hostname][, backlog][, callback])
If the hostname is omitted, the server will accept connections on any IPv6 address (::) when IPv6 is available, or any IPv4 address (0.0.0.0) otherwise

But the fact is both :: and 0.0.0.0 get listened.

I don't know which is correct? document or implementation? Anyway, this is a bit confusing.
Or maybe this is just a trick implementation of the Windows OS itself ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.netIssues and PRs related to the net subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions