func (c *Conn) Read(p []byte) (n int, err error) {
	c.readLock.Lock()
	defer c.readLock.Unlock()
	if c.readOffset == 0 {
		if err := c.Stream.RecvMsg(c.InMsg); err != nil {
			return 0, err
		}
	}
	data, err := c.Decode(c.InMsg, c.readOffset, p)
	if err != nil || len(data) <= (len(p)+c.readOffset) {
		n := len(data) - c.readOffset
		c.readOffset = 0
		c.InMsg.Reset()
		return n, err
	}
	c.readOffset += len(p)
	return len(p), err
}
Read implements io.Reader.
package grpc
import (
	"net"
	"sync"
	"time"
	"github.com/golang/protobuf/proto"
	"google.golang.org/grpc"
)
type Conn struct {
	Stream grpc.Stream
	InMsg proto.Message
	OutMsg proto.Message
	WriteLock *sync.Mutex
	Encode Encoder
	Decode Decoder
	readOffset int
	readLock, writeLock sync.Mutex
}