@@ -20,15 +20,17 @@ if (common.inFreeBSDJail){
2020return ;
2121}
2222
23+ let bindAddress = null ;
24+
2325// Take the first non-internal interface as the address for binding.
2426// Ideally, this should check for whether or not an interface is set up for
2527// BROADCAST and favor internal/private interfaces.
26- get_bindAddress: for ( var name in networkInterfaces ) {
27- var interfaces = networkInterfaces [ name ] ;
28- for ( var i = 0 ; i < interfaces . length ; i ++ ) {
29- var localInterface = interfaces [ i ] ;
28+ get_bindAddress: for ( const name in networkInterfaces ) {
29+ const interfaces = networkInterfaces [ name ] ;
30+ for ( let i = 0 ; i < interfaces . length ; i ++ ) {
31+ const localInterface = interfaces [ i ] ;
3032if ( ! localInterface . internal && localInterface . family === 'IPv4' ) {
31- var bindAddress = localInterface . address ;
33+ bindAddress = localInterface . address ;
3234break get_bindAddress;
3335}
3436}
@@ -56,9 +58,9 @@ if (process.argv[2] !== 'child'){
5658} , TIMEOUT ) ;
5759
5860//launch child processes
59- for ( var x = 0 ; x < listeners ; x ++ ) {
61+ for ( let x = 0 ; x < listeners ; x ++ ) {
6062( function ( ) {
61- var worker = fork ( process . argv [ 1 ] , [ 'child' ] ) ;
63+ const worker = fork ( process . argv [ 1 ] , [ 'child' ] ) ;
6264workers [ worker . pid ] = worker ;
6365
6466worker . messagesReceived = [ ] ;
@@ -68,7 +70,7 @@ if (process.argv[2] !== 'child'){
6870// don't consider this the true death if the worker
6971// has finished successfully
7072// or if the exit code is 0
71- if ( worker . isDone || code == 0 ) {
73+ if ( worker . isDone || code === 0 ) {
7274return ;
7375}
7476
@@ -113,12 +115,12 @@ if (process.argv[2] !== 'child'){
113115'messages. Will now compare.' ) ;
114116
115117Object . keys ( workers ) . forEach ( function ( pid ) {
116- var worker = workers [ pid ] ;
118+ const worker = workers [ pid ] ;
117119
118- var count = 0 ;
120+ let count = 0 ;
119121
120122worker . messagesReceived . forEach ( function ( buf ) {
121- for ( var i = 0 ; i < messages . length ; ++ i ) {
123+ for ( let i = 0 ; i < messages . length ; ++ i ) {
122124if ( buf . toString ( ) === messages [ i ] . toString ( ) ) {
123125count ++ ;
124126break ;
@@ -130,8 +132,11 @@ if (process.argv[2] !== 'child'){
130132worker . pid ,
131133count ) ;
132134
133- assert . equal ( count , messages . length ,
134- 'A worker received an invalid multicast message' ) ;
135+ assert . strictEqual (
136+ count ,
137+ messages . length ,
138+ 'A worker received an invalid multicast message'
139+ ) ;
135140} ) ;
136141
137142clearTimeout ( timer ) ;
@@ -143,7 +148,7 @@ if (process.argv[2] !== 'child'){
143148} ) ( x ) ;
144149}
145150
146- var sendSocket = dgram . createSocket ( {
151+ const sendSocket = dgram . createSocket ( {
147152type : 'udp4' ,
148153reuseAddr : true
149154} ) ;
@@ -160,7 +165,7 @@ if (process.argv[2] !== 'child'){
160165} ) ;
161166
162167sendSocket . sendNext = function ( ) {
163- var buf = messages [ i ++ ] ;
168+ const buf = messages [ i ++ ] ;
164169
165170if ( ! buf ) {
166171try { sendSocket . close ( ) ; } catch ( e ) { }
@@ -186,15 +191,15 @@ if (process.argv[2] !== 'child'){
186191
187192function killChildren ( children ) {
188193Object . keys ( children ) . forEach ( function ( key ) {
189- var child = children [ key ] ;
194+ const child = children [ key ] ;
190195child . kill ( ) ;
191196} ) ;
192197}
193198}
194199
195200if ( process . argv [ 2 ] === 'child' ) {
196- var receivedMessages = [ ] ;
197- var listenSocket = dgram . createSocket ( {
201+ const receivedMessages = [ ] ;
202+ const listenSocket = dgram . createSocket ( {
198203type : 'udp4' ,
199204reuseAddr : true
200205} ) ;
@@ -212,7 +217,7 @@ if (process.argv[2] === 'child'){
212217
213218process . send ( { message : buf . toString ( ) } ) ;
214219
215- if ( receivedMessages . length == messages . length ) {
220+ if ( receivedMessages . length === messages . length ) {
216221process . nextTick ( function ( ) {
217222listenSocket . close ( ) ;
218223} ) ;
0 commit comments