@@ -199,7 +199,7 @@ function bufferSize(self, size, buffer) {
199
199
Socket . prototype . bind = function ( port_ , address_ /* , callback */ ) {
200
200
let port = port_ ;
201
201
202
- this . _healthCheck ( ) ;
202
+ healthCheck ( this ) ;
203
203
204
204
if ( this . _bindState !== BIND_STATE_UNBOUND )
205
205
throw new ERR_SOCKET_ALREADY_BOUND ( ) ;
@@ -444,7 +444,7 @@ Socket.prototype.send = function(buffer,
444
444
throw new ERR_INVALID_ARG_TYPE ( 'address' , [ 'string' , 'falsy' ] , address ) ;
445
445
}
446
446
447
- this . _healthCheck ( ) ;
447
+ healthCheck ( this ) ;
448
448
449
449
if ( this . _bindState === BIND_STATE_UNBOUND )
450
450
this . bind ( { port : 0 , exclusive : true } , null ) ;
@@ -525,8 +525,8 @@ Socket.prototype.close = function(callback) {
525
525
return this ;
526
526
}
527
527
528
- this . _healthCheck ( ) ;
529
- this . _stopReceiving ( ) ;
528
+ healthCheck ( this ) ;
529
+ stopReceiving ( this ) ;
530
530
this . _handle . close ( ) ;
531
531
this . _handle = null ;
532
532
defaultTriggerAsyncIdScope ( this [ async_id_symbol ] ,
@@ -544,7 +544,7 @@ function socketCloseNT(self) {
544
544
545
545
546
546
Socket . prototype . address = function ( ) {
547
- this . _healthCheck ( ) ;
547
+ healthCheck ( this ) ;
548
548
549
549
var out = { } ;
550
550
var err = this . _handle . getsockname ( out ) ;
@@ -603,7 +603,7 @@ Socket.prototype.setMulticastLoopback = function(arg) {
603
603
604
604
605
605
Socket . prototype . setMulticastInterface = function ( interfaceAddress ) {
606
- this . _healthCheck ( ) ;
606
+ healthCheck ( this ) ;
607
607
608
608
if ( typeof interfaceAddress !== 'string' ) {
609
609
throw new ERR_INVALID_ARG_TYPE (
@@ -618,7 +618,7 @@ Socket.prototype.setMulticastInterface = function(interfaceAddress) {
618
618
619
619
Socket . prototype . addMembership = function ( multicastAddress ,
620
620
interfaceAddress ) {
621
- this . _healthCheck ( ) ;
621
+ healthCheck ( this ) ;
622
622
623
623
if ( ! multicastAddress ) {
624
624
throw new ERR_MISSING_ARGS ( 'multicastAddress' ) ;
@@ -633,7 +633,7 @@ Socket.prototype.addMembership = function(multicastAddress,
633
633
634
634
Socket . prototype . dropMembership = function ( multicastAddress ,
635
635
interfaceAddress ) {
636
- this . _healthCheck ( ) ;
636
+ healthCheck ( this ) ;
637
637
638
638
if ( ! multicastAddress ) {
639
639
throw new ERR_MISSING_ARGS ( 'multicastAddress' ) ;
@@ -646,22 +646,22 @@ Socket.prototype.dropMembership = function(multicastAddress,
646
646
} ;
647
647
648
648
649
- Socket . prototype . _healthCheck = function ( ) {
650
- if ( ! this . _handle ) {
649
+ function healthCheck ( socket ) {
650
+ if ( ! socket . _handle ) {
651
651
// Error message from dgram_legacy.js.
652
652
throw new ERR_SOCKET_DGRAM_NOT_RUNNING ( ) ;
653
653
}
654
- } ;
654
+ }
655
655
656
656
657
- Socket . prototype . _stopReceiving = function ( ) {
658
- if ( ! this . _receiving )
657
+ function stopReceiving ( socket ) {
658
+ if ( ! socket . _receiving )
659
659
return ;
660
660
661
- this . _handle . recvStop ( ) ;
662
- this . _receiving = false ;
663
- this . fd = null ; // compatibility hack
664
- } ;
661
+ socket . _handle . recvStop ( ) ;
662
+ socket . _receiving = false ;
663
+ socket . fd = null ; // compatibility hack
664
+ }
665
665
666
666
667
667
function onMessage ( nread , handle , buf , rinfo ) {
0 commit comments