func Test_listening3(t *testing.T) { listenOnNewConnections := func(t Tunnel) { for { fmt.Printf(string(t.Read())) } } //start the "server" listening targetPort := 10001 go Listen(targetPort, listenOnNewConnections) runtime.Gosched() tunnel := OpenTunnel("localhost", targetPort) var wg sync.WaitGroup wg.Add(1) go func() { for i := 0; i < 10; i++ { tunnel.Write([]byte("yo\n")) } wg.Done() }() OpenTunnel("localhost", targetPort) OpenTunnel("localhost", targetPort) wg.Wait() }