Skip to content

dgram: follow the same standard of net for the default address #5487

Description

@mcollina

In dgram, if you omit the address in send (https://nodejs.org/api/dgram.html#dgram_socket_send_msg_offset_length_port_address_callback), message is sent to '0.0.0.0' or '::0' whereas in net the default address for net.connect is 'localhost' (https://nodejs.org/api/net.html#net_net_connect_options_connectlistener).

This behavior has been around since forever, making dgram.send default address not reliable (see #5407 (comment)).

I propose to reconcile this two behavior, having dgram default to 'localhost' as well.

This will be a semver-major change.

cc @silverwind @rvagg @mafintosh @feross

Activity

  1. added
    dgramIssues and PRs related to UDP and the dgram module.
    on Feb 29, 2016
  2. rvagg commented on Feb 29, 2016

    @rvagg
    Member

    +1 for consistency, no opinion on which one is more correct, if you don't get any more comments here just move forward with a PR, that'll make sure any concerns come out

  3. silverwind commented on Feb 29, 2016

    @silverwind
    Contributor

    +1, sending to 0.0.0.0 is not what I would expect. Why doesn't it work on Windows, though?

  4. cjihrig commented on Feb 29, 2016

    @cjihrig
    Contributor

    +1 to using 'localhost'. IIRC, net was changed to localhost to avoid problems related to IPv4 vs. IPv6.

  5. mcollina commented on Feb 29, 2016

    @mcollina
    SponsorMemberAuthor

    @cjihrig when that was changed? Have you got a PR/issue so I can have a look around?

    @silverwind not exactly sure, @saghul knows better.

  6. feross commented on Feb 29, 2016

    @feross
    Contributor

    +1. I can't think of any reason to keep this inconsistent.

  7. saghul commented on Feb 29, 2016

    @saghul
    Member

    @mcollina I have no idea why it doesn't :-S Now, I think there are 2 different things here:

    • dgram.bind: this should bind to localhost
    • dgram.send: this should have the address as mandatory, IMHO (except if we introduce connected UDP sockets, which we don't have right now)
  8. cjihrig commented on Feb 29, 2016

    @cjihrig
    Contributor

    @mcollina sorry, I can't find an exact commit.

  9. mcollina commented on Feb 29, 2016

    @mcollina
    SponsorMemberAuthor

    Pr sent #5493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dgramIssues and PRs related to UDP and the dgram module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions