MCPcopy
hub / github.com/claude-code-best/claude-code / connectTcp

Method connectTcp

src/utils/pipeTransport.ts:386–411  ·  view source on GitHub ↗
(timeoutMs: number)

Source from the content-addressed store, hash-verified

384 }
385
386 private async connectTcp(timeoutMs: number): Promise<void> {
387 const { host, port } = this.tcpEndpoint!
388 return new Promise((resolve, reject) => {
389 const timer = setTimeout(() => {
390 reject(
391 new Error(
392 `TCP connection to "${this.targetName}" at ${host}:${port} timed out after ${timeoutMs}ms`,
393 ),
394 )
395 }, timeoutMs)
396
397 const socket = createConnection({ host, port }, () => {
398 clearTimeout(timer)
399 this.socket = socket
400 this.setupSocketListeners(socket)
401 this.emit('connected')
402 resolve()
403 })
404
405 socket.on('error', err => {
406 clearTimeout(timer)
407 socket.destroy()
408 reject(err)
409 })
410 })
411 }
412
413 private async connectUds(timeoutMs: number): Promise<void> {
414 const { access } = await import('fs/promises')

Callers 1

connectMethod · 0.95

Calls 5

setupSocketListenersMethod · 0.95
resolveFunction · 0.70
onMethod · 0.65
emitMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected