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

Function afterConnect

lib/net.js:1806–1877  ·  view source on GitHub ↗
(status, handle, req, readable, writable)

Source from the content-addressed store, hash-verified

1804
1805
1806function afterConnect(status, handle, req, readable, writable) {
1807 const self = handle[owner_symbol];
1808
1809 // Callback may come after call to destroy
1810 if (self.destroyed) {
1811 return;
1812 }
1813
1814 debug('afterConnect');
1815
1816 assert(self.connecting);
1817 self.connecting = false;
1818 self._sockname = null;
1819
1820 if (status === 0) {
1821 if (self.readable && !readable) {
1822 self.push(null);
1823 self.read();
1824 }
1825 if (self.writable && !writable) {
1826 self.end();
1827 }
1828 self._unrefTimer();
1829
1830 if (self[kSetNoDelay] && self._handle.setNoDelay) {
1831 self._handle.setNoDelay(true);
1832 }
1833
1834 if (self[kSetKeepAlive] && self._handle.setKeepAlive) {
1835 self._handle.setKeepAlive(true, self[kSetKeepAliveInitialDelay],
1836 self[kSetKeepAliveInterval],
1837 self[kSetKeepAliveCount]);
1838 }
1839
1840 if (self[kSetTOS] !== undefined && self._handle.setTypeOfService) {
1841 const err = self._handle.setTypeOfService(self[kSetTOS]);
1842 // On Windows, setting TOS is best-effort. If it fails, we shouldn't destroy
1843 // the connection or emit an error, as the socket is otherwise healthy.
1844 if (err && err !== UV_EBADF && !isWindows) {
1845 self.emit('error', new ErrnoException(err, 'setTypeOfService'));
1846 }
1847 }
1848
1849 self.emit('connect');
1850 self.emit('ready');
1851
1852 // Start the first read, or get an immediate EOF.
1853 // this doesn't actually consume any bytes, because len=0.
1854 if (readable && !self.isPaused())
1855 self.read(0);
1856 if (self[kPerfHooksNetConnectContext] && hasObserver('net')) {
1857 stopPerf(self, kPerfHooksNetConnectContext);
1858 }
1859 } else {
1860 let details;
1861 if (req.localAddress && req.localPort) {
1862 details = req.localAddress + ':' + req.localPort;
1863 }

Callers 1

afterConnectMultipleFunction · 0.85

Calls 10

hasObserverFunction · 0.85
stopPerfFunction · 0.85
isPausedMethod · 0.80
assertFunction · 0.70
debugFunction · 0.50
pushMethod · 0.45
readMethod · 0.45
endMethod · 0.45
emitMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…