@@ -34,7 +34,10 @@ if (process.argv[2] === 'child') {
34
34
// Datagram socket for udp uv handles.
35
35
const dgram = require ( 'dgram' ) ;
36
36
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
+ } ) ) ;
38
41
39
42
// Simple server/connection to create tcp uv handles.
40
43
const server = http . createServer ( ( req , res ) => {
@@ -50,6 +53,7 @@ if (process.argv[2] === 'child') {
50
53
server . close ( ( ) => {
51
54
if ( watcher ) watcher . close ( ) ;
52
55
fs . unwatchFile ( __filename ) ;
56
+ connected_udp_socket . close ( ) ;
53
57
udp_socket . close ( ) ;
54
58
process . removeListener ( 'disconnect' , exit ) ;
55
59
} ) ;
@@ -97,6 +101,7 @@ if (process.argv[2] === 'child') {
97
101
const prefix = common . isWindows ? '\\\\?\\' : '' ;
98
102
const expected_filename = `${ prefix } ${ __filename } ` ;
99
103
const found_tcp = [ ] ;
104
+ const found_udp = [ ] ;
100
105
// Functions are named to aid debugging when they are not called.
101
106
const validators = {
102
107
fs_event : common . mustCall ( function fs_event_validator ( handle ) {
@@ -138,10 +143,17 @@ if (process.argv[2] === 'child') {
138
143
assert . strictEqual ( handle . repeat , 0 ) ;
139
144
} ) ,
140
145
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
+ }
143
155
assert ( handle . is_referenced ) ;
144
- } ) ,
156
+ } , 2 ) ,
145
157
} ;
146
158
console . log ( report . libuv ) ;
147
159
for ( const entry of report . libuv ) {
@@ -150,6 +162,9 @@ if (process.argv[2] === 'child') {
150
162
for ( const socket of [ 'listening' , 'inbound' , 'outbound' ] ) {
151
163
assert ( found_tcp . includes ( socket ) , `${ socket } TCP socket was not found` ) ;
152
164
}
165
+ for ( const socket of [ 'connected' , 'unconnected' ] ) {
166
+ assert ( found_udp . includes ( socket ) , `${ socket } UDP socket was not found` ) ;
167
+ }
153
168
154
169
// Common report tests.
155
170
helper . validateContent ( stdout ) ;
0 commit comments