@@ -461,9 +461,12 @@ added: REPLACEME
461461
462462The synchronous counterpart of [ ` socket.connect() ` ] [ ] . For a UDP socket
463463` connect(2) ` only records the default peer address and is a local, non-blocking
464- system call, so the association is performed inline and any error such as
465- ` ECONNREFUSED ` is thrown synchronously rather than reported via the ` 'error' `
466- event:
464+ system call, so the association is performed inline. Any error raised by the
465+ call itself (for example ` EAFNOSUPPORT ` for a mismatched address family) is
466+ thrown synchronously rather than reported via the ` 'error' ` event. Because
467+ ` connect(2) ` does not probe reachability, errors such as ` ECONNREFUSED ` are
468+ still surfaced asynchronously on a later send or receive, exactly as for
469+ [ ` socket.connect() ` ] [ ] :
467470
468471``` js
469472const dgram = require (' node:dgram' );
@@ -477,7 +480,9 @@ If the socket is still unbound it is bound synchronously first. After
477480` connectSync() ` returns, [ ` socket.remoteAddress() ` ] [ ] is valid synchronously
478481and the ` 'connect' ` event is emitted on the next tick. Trying to call
479482` connectSync() ` on an already connected socket throws an
480- [ ` ERR_SOCKET_DGRAM_IS_CONNECTED ` ] [ ] exception.
483+ [ ` ERR_SOCKET_DGRAM_IS_CONNECTED ` ] [ ] exception, and calling it while an
484+ asynchronous [ ` socket.bind() ` ] [ ] is still in progress throws an
485+ [ ` ERR_SOCKET_ALREADY_BOUND ` ] [ ] exception.
481486
482487` address ` must be a numeric IP literal; ` connectSync() ` never performs DNS
483488resolution (asynchronous name resolution being the only genuinely blocking part
@@ -1090,6 +1095,7 @@ and `udp6` sockets). The bound address and port can be retrieved using
10901095[ RFC 4007 ] : https://tools.ietf.org/html/rfc4007
10911096[ `'close'` ] : #event-close
10921097[ `'message'` ] : #event-message
1098+ [ `ERR_SOCKET_ALREADY_BOUND` ] : errors.md#err_socket_already_bound
10931099[ `ERR_SOCKET_BAD_PORT` ] : errors.md#err_socket_bad_port
10941100[ `ERR_SOCKET_BUFFER_SIZE` ] : errors.md#err_socket_buffer_size
10951101[ `ERR_SOCKET_DGRAM_IS_CONNECTED` ] : errors.md#err_socket_dgram_is_connected
0 commit comments