@@ -34,7 +34,10 @@ if (process.argv[2] === 'child') {
3434 // Datagram socket for udp uv handles.
3535 const dgram = require ( 'dgram' ) ;
3636 const udp_socket = dgram . createSocket ( 'udp4' ) ;
37- udp_socket . bind ( { } ) ;
37+ const connected_udp_socket = dgram . createSocket ( 'udp4' ) ;
38+ udp_socket . bind ( { } , common . mustCall ( ( ) => {
39+ connected_udp_socket . connect ( udp_socket . address ( ) . port ) ;
40+ } ) ) ;
3841
3942 // Simple server/connection to create tcp uv handles.
4043 const server = http . createServer ( ( req , res ) => {
@@ -50,6 +53,7 @@ if (process.argv[2] === 'child') {
5053 server . close ( ( ) => {
5154 if ( watcher ) watcher . close ( ) ;
5255 fs . unwatchFile ( __filename ) ;
56+ connected_udp_socket . close ( ) ;
5357 udp_socket . close ( ) ;
5458 process . removeListener ( 'disconnect' , exit ) ;
5559 } ) ;
@@ -97,6 +101,7 @@ if (process.argv[2] === 'child') {
97101 const prefix = common . isWindows ? '\\\\?\\' : '' ;
98102 const expected_filename = `${ prefix } ${ __filename } ` ;
99103 const found_tcp = [ ] ;
104+ const found_udp = [ ] ;
100105 // Functions are named to aid debugging when they are not called.
101106 const validators = {
102107 fs_event : common . mustCall ( function fs_event_validator ( handle ) {
@@ -138,10 +143,17 @@ if (process.argv[2] === 'child') {
138143 assert . strictEqual ( handle . repeat , 0 ) ;
139144 } ) ,
140145 udp : common . mustCall ( function udp_validator ( handle ) {
141- assert . strictEqual ( handle . localEndpoint . port ,
142- child_data . udp_address . port ) ;
146+ if ( handle . remoteEndpoint === null ) {
147+ assert . strictEqual ( handle . localEndpoint . port ,
148+ child_data . udp_address . port ) ;
149+ found_udp . push ( 'unconnected' ) ;
150+ } else {
151+ assert . strictEqual ( handle . remoteEndpoint . port ,
152+ child_data . udp_address . port ) ;
153+ found_udp . push ( 'connected' ) ;
154+ }
143155 assert ( handle . is_referenced ) ;
144- } ) ,
156+ } , 2 ) ,
145157 } ;
146158 console . log ( report . libuv ) ;
147159 for ( const entry of report . libuv ) {
@@ -150,6 +162,9 @@ if (process.argv[2] === 'child') {
150162 for ( const socket of [ 'listening' , 'inbound' , 'outbound' ] ) {
151163 assert ( found_tcp . includes ( socket ) , `${ socket } TCP socket was not found` ) ;
152164 }
165+ for ( const socket of [ 'connected' , 'unconnected' ] ) {
166+ assert ( found_udp . includes ( socket ) , `${ socket } UDP socket was not found` ) ;
167+ }
153168
154169 // Common report tests.
155170 helper . validateContent ( stdout ) ;
0 commit comments