MCPcopy Create free account
hub / github.com/anchordotdev/cli / waitTCP

Method waitTCP

api/apitest/apitest.go:285–306  ·  view source on GitHub ↗
(addr string)

Source from the content-addressed store, hash-verified

283}
284
285func (s *Server) waitTCP(addr string) error {
286 var dialer net.Dialer
287
288 duration := 16 * time.Second
289 ctx, cancel := context.WithTimeoutCause(
290 context.Background(),
291 duration,
292 fmt.Errorf("waitTcp %s timeout waiting for: %s", duration, addr),
293 )
294 defer cancel()
295
296 for {
297 if conn, err := dialer.DialContext(ctx, "tcp4", addr); err == nil {
298 conn.Close()
299 return nil
300 } else if !isConnRefused(err) {
301 return err
302 }
303
304 time.Sleep(10 * time.Millisecond)
305 }
306}
307
308func drainCmd(cmd *exec.Cmd) (func() error, error) {
309 stdout, err := cmd.StdoutPipe()

Callers 2

StartMockMethod · 0.95
StartProxyMethod · 0.95

Calls 3

DialContextMethod · 0.95
isConnRefusedFunction · 0.70
CloseMethod · 0.45

Tested by

no test coverage detected