MCPcopy Index your code
hub / github.com/inkeep/open-knowledge / tcpConnect

Function tcpConnect

packages/cli/tests/e2e/cli-linux-e2e.ts:69–81  ·  view source on GitHub ↗
(host: string, port: number, timeoutMs: number)

Source from the content-addressed store, hash-verified

67}
68
69function tcpConnect(host: string, port: number, timeoutMs: number): Promise<boolean> {
70 return new Promise((res) => {
71 const sock = connect({ host, port });
72 const done = (ok: boolean) => {
73 sock.destroy();
74 res(ok);
75 };
76 sock.setTimeout(timeoutMs);
77 sock.once('connect', () => done(true));
78 sock.once('timeout', () => done(false));
79 sock.once('error', () => done(false));
80 });
81}
82
83async function tcpReachable(port: number, timeoutMs = 2000): Promise<boolean> {
84 const [v4, v6] = await Promise.all([

Callers 1

tcpReachableFunction · 0.85

Calls 4

doneFunction · 0.70
setTimeoutMethod · 0.65
onceMethod · 0.65
connectFunction · 0.50

Tested by

no test coverage detected