MCPcopy
hub / github.com/kubernetes/client-go / waitForConnection

Method waitForConnection

tools/portforward/portforward.go:300–312  ·  view source on GitHub ↗

waitForConnection waits for new connections to listener and handles them in the background.

(listener net.Listener, port ForwardedPort)

Source from the content-addressed store, hash-verified

298// waitForConnection waits for new connections to listener and handles them in
299// the background.
300func (pf *PortForwarder) waitForConnection(listener net.Listener, port ForwardedPort) {
301 for {
302 conn, err := listener.Accept()
303 if err != nil {
304 // TODO consider using something like https://github.com/hydrogen18/stoppableListener?
305 if !strings.Contains(strings.ToLower(err.Error()), "use of closed network connection") {
306 runtime.HandleError(fmt.Errorf("Error accepting connection on port %d: %v", port.Local, err))
307 }
308 return
309 }
310 go pf.handleConnection(conn, port)
311 }
312}
313
314func (pf *PortForwarder) nextRequestID() int {
315 pf.requestIDLock.Lock()

Callers 1

Calls 4

handleConnectionMethod · 0.95
AcceptMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected