waitForConnection waits for new connections to listener and handles them in the background.
(listener net.Listener, port ForwardedPort)
| 298 | // waitForConnection waits for new connections to listener and handles them in |
| 299 | // the background. |
| 300 | func (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 | |
| 314 | func (pf *PortForwarder) nextRequestID() int { |
| 315 | pf.requestIDLock.Lock() |
no test coverage detected