You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
send: null 2
dgram.js:249
throw new RangeError('Offset into buffer too large');
^
RangeError: Offset into buffer too large
at Socket.send (dgram.js:249:11)
at Object.callback (/home/bentkus/Projects/c/node/udp.js:12:4)
at Object.afterSend [as oncomplete] (dgram.js:322:8)
You see that we pass 0 as the length parameter, yet we get the length of the buffer in the callback even though we sent an empty packet over there wire (I checked with wireshark) we get a 2 in return (which is the size of the buffer).
Second bug:
The callback doesn't get called, because of this guard checking for nread == 0. It should actually check (nread == 0 && addr == NULL). Remember UDP packets can have no content, so 0 length.
dgram.js:249
throw new RangeError('Offset into buffer too large');
^
RangeError: Offset into buffer too large
at Socket.send (dgram.js:249:11)
at Object.callback (/home/bentkus/Projects/c/node/udp.js:12:4)
at Object.afterSend [as oncomplete] (dgram.js:322:8)
We have an offset of 0, length of 0 and the buffer length is 0. So this exception actually shouldn't occur.
The text was updated successfully, but these errors were encountered:
First of all: You can send UDP packets 0 content (no data at all, only udp headers) over the wire.
This issue has 3 bugs, I'll start with some code and the output and then explain what is wrong.
The output:
Let's start with
If you take a look on
You see that we pass 0 as the length parameter, yet we get the length of the buffer in the callback even though we sent an empty packet over there wire (I checked with wireshark) we get a 2 in return (which is the size of the buffer).
Second bug:
The callback doesn't get called, because of this guard checking for nread == 0. It should actually check (nread == 0 && addr == NULL). Remember UDP packets can have no content, so 0 length.
Third bug:
is throwing:
We have an offset of 0, length of 0 and the buffer length is 0. So this exception actually shouldn't occur.
The text was updated successfully, but these errors were encountered: