func (p *HalfConn) Read(b []byte) (n int, err error) {
	if len(b) == 0 {
		panic("trivial buffer")
	}
	p.recv__.Lock()
	defer p.recv__.Unlock()

	// Read left-over data
	if n, _ = p.buf.Read(b); n > 0 {
		return n, nil
	}
	if p.buf.Len() != 0 {
		panic("u")
	}

	// Receive more data if capacity left in the user read buffer.
	// Close on this endpoint should not interrupt reading; reading has to be closed explicitly by the remote endpoint.
	t, ok := <-p.recv
	if !ok {
		return 0, io.ErrUnexpectedEOF
	}
	switch q := t.(type) {
	case []byte:
		if len(q) == 0 {
			panic("eh")
		}
		//p.frame.Printf("Read: #%v", q)
		// Write new data to internal read buffer
		if m, err := p.buf.Write(q); err != nil || m != len(q) {
			log.Printf("buf write %d/%d (%v)", m, len(q), err)
			panic("u/e")
		}
		// Read new data into user read buffer
		n, _ = p.buf.Read(b)
		return n, nil
	case eof:
		return 0, io.EOF
	}
	panic("eh")
}
// Read reads from the connection. Graceful closure on the remote side is returned as io.EOF.
Read reads from the connection. Graceful closure on the remote side is returned as io.EOF.
// Read reads from the connection . Graceful closure on the remote side is returned as io . EOF .
func (p *HalfConn) Read(b []byte) (n int, err error) {
	if len(b) == 0 {
		panic("trivial buffer")
	}
	p.recv__.Lock()
	defer p.recv__.Unlock()
	if n, _ = p.buf.Read(b); n > 0 {
		return n, nil
	}
	if p.buf.Len() != 0 {
		panic("u")
	}
	t, ok := <-p.recv
	if !ok {
		return 0, io.ErrUnexpectedEOF
	}
	switch q := t.(type) {
	case []byte:
		if len(q) == 0 {
			panic("eh")
		}
		if m, err := p.buf.Write(q); err != nil || m != len(q) {
			log.Printf("buf write %d/%d (%v)", m, len(q), err)
			panic("u/e")
		}
		n, _ = p.buf.Read(b)
		return n, nil
	case eof:
		return 0, io.EOF
	}
	panic("eh")
}
func ( p * HalfConn ) Read ( b [ ] byte ) ( n int , err error ) { if len ( b ) == 0 { panic ( " " ) } p . recv__ . Lock ( ) defer p . recv__ . Unlock ( ) if n , _ = p . buf . Read ( b ) ; n > 0 { return n , nil } if p . buf . Len ( ) != 0 { panic ( " " ) } t , ok := <- p . recv if ! ok { return 0 , io . ErrUnexpectedEOF } switch q := t . ( type ) { case [ ] byte : if len ( q ) == 0 { panic ( " " ) } if m , err := p . buf . Write ( q ) ; err != nil || m != len ( q ) { log . Printf ( " " , m , len ( q ) , err ) panic ( " " ) } n , _ = p . buf . Read ( b ) return n , nil case eof : return 0 , io . EOF } panic ( " " ) }
Read reads from the connection.
Read reads from the connection .
// Read left-over data // Receive more data if capacity left in the user read buffer. // Close on this endpoint should not interrupt reading; reading has to be closed explicitly by the remote endpoint. //p.frame.Printf("Read: #%v", q) // Write new data to internal read buffer // Read new data into user read buffer