| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e1fc9b9 commit 0716944
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -561,16 +561,19 @@ Socket.prototype.send = function(buffer, | |||
| 561 | 561 | port = offset; | |
| 562 | 562 | address = length; | |
| 563 | 563 | } | |
| 564 | - } else if (typeof length === 'number') { | ||
| 565 | - buffer = sliceBuffer(buffer, offset, length); | ||
| 566 | - if (typeof port === 'function') { | ||
| 567 | - callback = port; | ||
| 568 | - port = null; | ||
| 569 | - } else if (port || address) { | ||
| 570 | - throw new ERR_SOCKET_DGRAM_IS_CONNECTED(); | ||
| 571 | - } | ||
| 572 | 564 | } else { | |
| 573 | - callback = offset; | ||
| 565 | + if (typeof length === 'number') { | ||
| 566 | + buffer = sliceBuffer(buffer, offset, length); | ||
| 567 | + if (typeof port === 'function') { | ||
| 568 | + callback = port; | ||
| 569 | + port = null; | ||
| 570 | + } | ||
| 571 | + } else { | ||
| 572 | + callback = offset; | ||
| 573 | + } | ||
| 574 | + | ||
| 575 | + if (port || address) | ||
| 576 | + throw new ERR_SOCKET_DGRAM_IS_CONNECTED(); | ||
| 574 | 577 | } | |
| 575 | 578 | ||
| 576 | 579 | if (!Array.isArray(buffer)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,15 @@ function checkArgs(connected) { | |||
| 68 | 68 | message: 'Already connected' | |
| 69 | 69 | } | |
| 70 | 70 | ); | |
| 71 | + | ||
| 72 | + common.expectsError( | ||
| 73 | + () => { sock.send(buf, 1234, '127.0.0.1', common.mustNotCall()); }, | ||
| 74 | + { | ||
| 75 | + code: 'ERR_SOCKET_DGRAM_IS_CONNECTED', | ||
| 76 | + type: Error, | ||
| 77 | + message: 'Already connected' | ||
| 78 | + } | ||
| 79 | + ); | ||
| 71 | 80 | } else { | |
| 72 | 81 | assert.throws(() => { sock.send(buf, 1, 1, -1, host); }, RangeError); | |
| 73 | 82 | assert.throws(() => { sock.send(buf, 1, 1, 0, host); }, RangeError); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments