Skip to content

Commit 164461e

Browse files
rickyescodebytere
authored andcommitted
net: refactor check for Windows
PR-URL: #33497 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent af9fb59 commit 164461e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎lib/net.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ const { kTimeout } = require('internal/timers');
119119
constDEFAULT_IPV4_ADDR='0.0.0.0';
120120
constDEFAULT_IPV6_ADDR='::';
121121

122+
constisWindows=process.platform==='win32';
123+
122124
functionnoop(){}
123125

124126
functiongetFlags(ipv6Only){
@@ -335,8 +337,7 @@ function Socket(options) {
335337
this[async_id_symbol]=this._handle.getAsyncId();
336338

337339
if((fd===1||fd===2)&&
338-
(this._handleinstanceofPipe)&&
339-
process.platform==='win32'){
340+
(this._handleinstanceofPipe)&&isWindows){
340341
// Make stdout and stderr blocking on Windows
341342
err=this._handle.setBlocking(true);
342343
if(err)
@@ -1024,7 +1025,7 @@ function lookupAndConnect(self, options) {
10241025
hints: options.hints||0
10251026
};
10261027

1027-
if(process.platform!=='win32'&&
1028+
if(!isWindows&&
10281029
dnsopts.family!==4&&
10291030
dnsopts.family!==6&&
10301031
dnsopts.hints===0){
@@ -1227,7 +1228,7 @@ function createServerHandle(address, port, addressType, fd, flags) {
12271228
assert(!address&&!port);
12281229
}elseif(port===-1&&addressType===-1){
12291230
handle=newPipe(PipeConstants.SERVER);
1230-
if(process.platform==='win32'){
1231+
if(isWindows){
12311232
constinstances=parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
12321233
if(!NumberIsNaN(instances)){
12331234
handle.setPendingInstances(instances);
@@ -1710,7 +1711,7 @@ Server.prototype.unref = function() {
17101711
let_setSimultaneousAccepts;
17111712
letwarnSimultaneousAccepts=true;
17121713

1713-
if(process.platform==='win32'){
1714+
if(isWindows){
17141715
letsimultaneousAccepts;
17151716

17161717
_setSimultaneousAccepts=function(handle){

0 commit comments

Comments
 (0)