コード例 #1
0
func MessToStream(mess io.ReadWriteCloser) io.ReadWriteCloser {
	var toret m2s_provider
	toret.underlying = mess
	toret.buffer = common.NewBufferedPipe()
	go func() {
		bts := make([]byte, 65536)
		defer toret.underlying.Close()
		defer toret.buffer.Close()
		for {
			n, err := toret.underlying.Read(bts)
			if err != nil {
				return
			}
			_, err = toret.buffer.Write(bts[:n])
			if err != nil {
				return
			}
		}
	}()
	return &toret
}
コード例 #2
0
func new_vs() *virtsock {
	return &virtsock{common.NewBufferedPipe(), common.NewBufferedPipe()}
}