-
Notifications
You must be signed in to change notification settings - Fork 7.3k
net: net.Server.address() behaves inconsistently #7675
Comments
This is by design: node v0.11 listens on both protocols by default now. |
Two more questions:
|
It should be.
I observe that:
Which feels rather incongruent. I suggest making 1 consistent with 2. |
Can we reopen the issue? |
See nodejs#7675 net.server.listen() behaves inconsistently depending on whether the port number is provided. 1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET socket but does not call bind(). 2. port > 0 && host == '', node creates an AF_INET6 socket and calls bind(). The fix makes 1 consistent with 2.
See nodejs#7675 net.server.listen() behaves inconsistently depending on whether the port number is provided. 1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET socket but does not call bind(). 2. port > 0 && host == '', node creates an AF_INET6 socket and calls bind(). The fix makes 1 consistent with 2.
See nodejs#7675 net.server.listen() behaves inconsistently depending on whether the port number is provided. 1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET socket but does not call bind(). 2. port > 0 && host == '', node creates an AF_INET6 socket and calls bind(). The fix makes 1 consistent with 2.
See #7675 net.server.listen() behaves inconsistently depending on whether the port number is provided. 1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET socket but does not call bind(). 2. port > 0 && host == '', node creates an AF_INET6 socket and calls bind(). The fix makes 1 consistent with 2. Signed-off-by: Fedor Indutny <[email protected]>
@raymondfeng @indutny The new behavior doesn't seem to be documented. server.listen's doc still states:
Did I miss something? If not, I suggest updating the doc. Should I create a new PR for this? |
Just wanted to mention that this is biting in an attempt to upgrade to Node v0.12 - Documentation isn't much help here - it appears to be out of date and doesn't tell me what the expected behavior is, or how to bind to IPv4 only. |
@STRML It seems that the documentation is lacking in this regard, thank you for pointing that out. I created #9239 to track this. I came across similar issues in other projects in the past, for instance in express. Instead of having IP addresses tests rely on a specific address family/protocol, the tests were fixed to "discover" what protocol/address family is used at runtime. Does that help you solve your problem? |
That seems like a decent way to do it. Perhaps it would be best for express to deprecate For test suites, it would be very helpful if the old behavior could be forced via an environment variable, rather than using these IPv6 mapped addresses. There are plenty of legacy libraries out there that will expect the old behavior and I expect this to be a source of grief for a long time to come. |
See nodejs/node-v0.x-archive#7675 net.server.listen() behaves inconsistently depending on whether the port number is provided. 1. port === 0 && host == '' (i.e. false-y), node creates an AF_INET socket but does not call bind(). 2. port > 0 && host == '', node creates an AF_INET6 socket and calls bind(). The fix makes 1 consistent with 2. Signed-off-by: Fedor Indutny <[email protected]>
net.Server.address() returns IPV4/IPV6 inconsistently. To reproduce the problem, run the following test with v0.10.28 and v0.11.13.
Result from v0.10.28:
Result from v0.11.13:
Is this a bug or by design?
The text was updated successfully, but these errors were encountered: