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

Function checkBindError

lib/net.js:1230–1248  ·  view source on GitHub ↗
(err, port, handle)

Source from the content-addressed store, hash-verified

1228
1229
1230function checkBindError(err, port, handle) {
1231 // EADDRINUSE may not be reported until we call listen() or connect().
1232 // To complicate matters, a failed bind() followed by listen() or connect()
1233 // will implicitly bind to a random port. Ergo, check that the socket is
1234 // bound to the expected port before calling listen() or connect().
1235 //
1236 // FIXME(bnoordhuis) Doesn't work for pipe handles, they don't have a
1237 // getsockname() method. Non-issue for now, the cluster module doesn't
1238 // really support pipes anyway.
1239 if (err === 0 && port > 0 && handle.getsockname) {
1240 const out = {};
1241 err = handle.getsockname(out);
1242 if (err === 0 && port !== out.port) {
1243 debug(`checkBindError, bound to ${out.port} instead of ${port}`);
1244 err = UV_EADDRINUSE;
1245 }
1246 }
1247 return err;
1248}
1249
1250
1251function internalConnect(

Callers 3

internalConnectFunction · 0.85
internalConnectMultipleFunction · 0.85
listenOnPrimaryHandleFunction · 0.85

Calls 1

debugFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…