Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgram socket.send() documentation needs clarification #5124

Closed
Trott opened this issue Feb 6, 2016 · 6 comments
Closed

dgram socket.send() documentation needs clarification #5124

Trott opened this issue Feb 6, 2016 · 6 comments
Assignees
Labels
dgram Issues and PRs related to the dgram subsystem / UDP. doc Issues and PRs related to the documentations.

Comments

@Trott
Copy link
Member

Trott commented Feb 6, 2016

In the version of the dgram doc that is current as of this writing, the first argument (buf) is described initially as:

Buffer object, string, or an array of either. Message to be sent.

However, it is subsequently described as a Buffer object only:

The buf argument is a [Buffer] object containing the message. The offset
and length specify the offset within the Buffer where the message begins
and the number of bytes in the message, respectively. With messages that
contain multi-byte characters, offset and length will be calculated with
respect to [byte length][] and not the character position.

Additionally, it is not clear what offset and length mean when the buf argument is an array. It's also not clear if the multi-byte caveat applies if buf is a string or only if buf is a Buffer object.

It may be worth changing the name from buf to msg or something like that.

/cc @nodejs/documentation

@Trott Trott added dgram Issues and PRs related to the dgram subsystem / UDP. doc Issues and PRs related to the documentations. labels Feb 6, 2016
@silverwind
Copy link
Contributor

cc: @mcollina

@eljefedelrodeodeljefe
Copy link
Contributor

That is a very good idea, if this is working correctly.

@mcollina
Copy link
Member

mcollina commented Feb 7, 2016

Thanks @silverwind! And thanks for reviewing @Trott!

@eljefedelrodeodeljefe what do you refer to? #4374 should work as expected yes.

Just to clarify:

  1. offset and len means nothing if an array is passed.
  2. you can pass strings in the array form, which will be converted to Buffer with 'utf8' encoding. (this was never specified even in the original docs).

It may be worth changing the name from buf to msg or something like that.

yes, agreed.

I will send a PR to update the docs and resolve this.

@eljefedelrodeodeljefe
Copy link
Contributor

@mcollina nothing special. Just haven't tested passing non-Buffer primitives.

@mcollina
Copy link
Member

mcollina commented Feb 7, 2016

@eljefedelrodeodeljefe please do :).

@mcollina
Copy link
Member

mcollina commented Feb 7, 2016

PR sent #5130

mcollina added a commit to mcollina/node that referenced this issue Feb 7, 2016
rvagg pushed a commit that referenced this issue Feb 9, 2016
Fixes: #5124
See: #4374
PR-URL: #5130
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
rvagg pushed a commit that referenced this issue Feb 9, 2016
Fixes: #5124
See: #4374
PR-URL: #5130
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: James M Snell <[email protected]>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dgram Issues and PRs related to the dgram subsystem / UDP. doc Issues and PRs related to the documentations.
Projects
None yet
Development

No branches or pull requests

4 participants