INNER CODE UNIT · Go

dialer

docker/compose · relay/main.go:192

	dialer := net.Dialer{Timeout: 10 * time.Second}
	up, err := dialer.Dial("tcp", upstream)
	if err != nil {
		log.Printf("dial %s: %v", upstream, err)
		return
	}
	defer func() { _ = up.Close() }()

	down := &idleConn{Conn: downstream}
	upc := &idleConn{Conn: up}
	done := make(chan struct{}, 2)
	go func() { _, _ = io.Copy(up, down); closeWrite(up); done <- struct{}{} }()
	go func() { _, _ = io.Copy(downstream, upc); closeWrite(downstream); done <- struct{}{} }()
	<-done
	// One direction is done: from here on the survivor may stream for as
	// long as data flows, but no longer sit idle forever. Arm the per-read
	// deadline for its future Reads, and set one immediately for a survivor
	// already blocked in Read.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…