1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-18 10:26:01 -05:00
v2fly/common/io/transport.go
2016-08-20 20:55:45 +02:00

28 lines
407 B
Go

package io
import (
"v2ray.com/core/common/log"
)
func Pipe(reader Reader, writer Writer) error {
for {
buffer, err := reader.Read()
if err != nil {
log.Debug("IO: Pipe exits as ", err)
return err
}
if buffer.IsEmpty() {
buffer.Release()
continue
}
err = writer.Write(buffer)
if err != nil {
log.Debug("IO: Pipe exits as ", err)
buffer.Release()
return err
}
}
}