converge/pkg/iowrappers/sync.go
Erik Brakkee cfccf04f9d working server
* administration appears coorect
* multiple clients for one agent
* logging of active connections
* simple echo server on the agent.
2024-07-20 13:35:49 +02:00

32 lines
512 B
Go

package iowrappers
import (
"io"
"log"
)
func SynchronizeStreams(stream1, stream2 io.ReadWriter) {
waitChannel := make(chan bool)
go func() {
defer func() {
waitChannel <- true
}()
_, err := io.Copy(stream1, stream2)
if err != nil {
log.Printf("sync streams error(1) %v\n", err)
}
}()
go func() {
defer func() {
waitChannel <- true
}()
_, err := io.Copy(stream2, stream1)
log.Printf("sync streams error(2) %v\n", err)
}()
<-waitChannel
log.Println("Connection closed")
}