MCPcopy Index your code
hub / github.com/nodejs/node / connect

Function connect

lib/internal/quic/quic.js:5363–5402  ·  view source on GitHub ↗

* @param {string|SocketAddress} address * @param {SessionOptions} [options] * @returns {Promise }

(address, options = kEmptyObject)

Source from the content-addressed store, hash-verified

5361 * @returns {Promise<QuicSession>}
5362 */
5363async function connect(address, options = kEmptyObject) {
5364 if (typeof address === 'string') {
5365 address = SocketAddress.parse(address);
5366 }
5367
5368 if (!SocketAddress.isSocketAddress(address)) {
5369 if (address == null || typeof address !== 'object') {
5370 throw new ERR_INVALID_ARG_TYPE('address', ['SocketAddress', 'string'], address);
5371 }
5372 address = new SocketAddress(address);
5373 }
5374
5375 const {
5376 endpoint,
5377 ...rest
5378 } = processSessionOptions(options, { targetAddress: address });
5379
5380 if (onEndpointConnectChannel.hasSubscribers) {
5381 onEndpointConnectChannel.publish({
5382 __proto__: null,
5383 endpoint,
5384 address,
5385 options,
5386 });
5387 }
5388
5389 const session = endpoint[kConnect](address[kSocketAddressHandle], rest);
5390
5391 if (onEndpointClientSessionChannel.hasSubscribers) {
5392 onEndpointClientSessionChannel.publish({
5393 __proto__: null,
5394 endpoint,
5395 session,
5396 address,
5397 options,
5398 });
5399 }
5400
5401 return session;
5402}
5403
5404ObjectDefineProperties(QuicEndpoint, {
5405 Stats: {

Callers

nothing calls this directly

Calls 4

processSessionOptionsFunction · 0.85
isSocketAddressMethod · 0.80
parseMethod · 0.65
publishMethod · 0.45

Tested by

no test coverage detected