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

Function doConnect

lib/dgram.js:576–604  ·  view source on GitHub ↗
(ex, self, ip, address, port, callback)

Source from the content-addressed store, hash-verified

574
575
576function doConnect(ex, self, ip, address, port, callback) {
577 const state = self[kStateSymbol];
578 if (!state.handle)
579 return;
580 if (!ex && state.sendBlockList?.check(ip, `ipv${isIP(ip)}`)) {
581 ex = new ERR_IP_BLOCKED(ip);
582 }
583 if (!ex) {
584 const err = state.handle.connect(ip, port);
585 if (err) {
586 ex = new ExceptionWithHostPort(err, 'connect', address, port);
587 }
588 }
589
590 if (ex) {
591 state.connectState = CONNECT_STATE_DISCONNECTED;
592 return process.nextTick(() => {
593 if (callback) {
594 self.removeListener('connect', callback);
595 callback(ex);
596 } else {
597 self.emit('error', ex);
598 }
599 });
600 }
601
602 state.connectState = CONNECT_STATE_CONNECTED;
603 process.nextTick(() => self.emit('connect'));
604}
605
606
607Socket.prototype.disconnect = function() {

Callers

nothing calls this directly

Calls 6

isIPFunction · 0.85
connectMethod · 0.65
callbackFunction · 0.50
checkMethod · 0.45
removeListenerMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…