// Read implements the read interface of the connection.
554983
func (c UIDConnection) Read(b []byte) (n int, err error) {
	return c.nc.Read(b)
}
515170
func (client *socketClient) Read() (msg []byte, err error) {
	_, msg, err = client.conn.ReadMessage()
	return
}
964092
func (r *Reader) Read(b []byte) (n int, err error) {
	if len(b) == 0 {
		return 0, nil
	}
	if r.pos >= len(r.buf) {
		return 0, io.EOF
	}
	n = copy(b, r.buf[r.pos:])
	r.pos += n
	return
}
1246714
func (r *Reader) Read() ([]byte, error) {
	r.Lock()
	defer r.Unlock()

	if _, err := io.ReadFull(r.r, r.buff[:]); err != nil {
		return nil, err
	}

	length := int64(binary.BigEndian.Uint32(r.buff[:]))
	if length < _fastPathFrameSize {
		return r.readFastPath(length)
	}

	var buff bytes.Buffer
	_, err := io.CopyN(&buff, r.r, length)
	if err != nil {
		return nil, err
	}

	return buff.Bytes(), nil
}
1045860
func (c *proxyProtocolConn) Read(buffer []byte) (int, error) {
	if c.exceedBufferReaded {
		return c.Conn.Read(buffer)
	}
	if c.exceedBufferLen == 0 || c.exceedBufferStart >= c.exceedBufferLen {
		c.exceedBufferReaded = true
		return c.Conn.Read(buffer)
	}

	buflen := len(buffer)
	nExceedRead := c.exceedBufferLen - c.exceedBufferStart
	// buffer length is less or equals than exceedBuffer length
	if nExceedRead >= buflen {
		copy(buffer[0:], c.exceedBuffer[c.exceedBufferStart:c.exceedBufferStart+buflen])
		c.exceedBufferStart += buflen
		return buflen, nil
	}
	// buffer length is great than exceedBuffer length
	copy(buffer[0:nExceedRead], c.exceedBuffer[c.exceedBufferStart:])
	n, err := c.Conn.Read(buffer[nExceedRead-1:])
	if err == nil {
		// If read is success set buffer start to buffer length
		// If fail make rest buffer can be read in next time
		c.exceedBufferStart = c.exceedBufferLen
		return n + nExceedRead - 1, nil
	}
	return 0, err
}
942626
func (c *Conn) Read(b []byte) (int, error) {
	if !c.ok() {
		return 0, syscall.EINVAL
	}
	if !c.isOpen() {
		return 0, &net.OpError{
			Op:   "read",
			Net:  c.LocalAddr().Network(),
			Addr: c.LocalAddr(),
			Err:  errClosing,
		}
	}
	s := c.readbuf.space()
	c.deadlineMutex.RLock()
	d := timeToDeadline(c.rdeadline)
	c.deadlineMutex.RUnlock()
	l, err := c.readbuf.ReadTimeout(b, d)
	if s < mss && c.readbuf.space() > 0 {
		select {
		case c.ackch <- 0:
		default:
		}
	}
	return l, err
}
270691
func (c *conn) Read(b []byte) (int, error) {
	return c.buf.Read(b)
}
579641
func Read(r *bufio.Reader) Value {
	res, _ := ReadValue(r)
	return res
}
512542
func (p *ProxiedConnection) Read(b []byte) (n int, err error) {
	return p.originalTCPConnection.Read(b)
}
77881
func (c *i2cConnection) Read(data []byte) (read int, err error) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	if err = c.bus.SetAddress(c.address); err != nil {
		return 0, err
	}
	read, err = c.bus.Read(data)
	return
}
232099
func (rd *Reader) Read(b []byte) (n int, err error) {
	if rd.nb == 0 {
		return 0, io.EOF
	}
	if int64(len(b)) > rd.nb {
		b = b[0:rd.nb]
	}
	n, err = rd.r.Read(b)
	rd.nb -= int64(n)

	return
}
396099
func (con *Connection) Read(b []byte) (int, error) {
	if con.getDecrypter() != nil {
		return con.DecryptedRead(b)
	}

	return con.connection.Read(b)
}
361941
func (c *connection) read(timeout time.Duration) ([]byte, error) {
	if !c.available() {
		return nil, ErrCannotRead
	}

	var err error
	var count int
	var messageLength uint32
	var rt time.Duration = timeout // rt = 'read timeout'
	b := &backoff.Backoff{
		Min:    rt,
		Jitter: true,
	}
	try := uint16(0)

	for {
		c.setReadDeadline(rt)
		if count, err = io.ReadFull(c.conn, c.sizeBuf); err == nil && count == 4 {
			messageLength = binary.BigEndian.Uint32(c.sizeBuf)
			if messageLength > uint32(cap(c.dataBuf)) {
				logDebug("[Connection]", "allocating larger dataBuf of size %d", messageLength)
				c.dataBuf = make([]byte, messageLength)
			} else {
				c.dataBuf = c.dataBuf[0:messageLength]
			}
			// FUTURE: large object warning / error
			// TODO: FUTURE this deadline should subtract the duration taken by the first
			// ReadFull call. Currently it's could wait up to 2X the read timout value
			c.setReadDeadline(rt)
			count, err = io.ReadFull(c.conn, c.dataBuf)
		} else {
			if err == nil && count != 4 {
				err = newClientError(fmt.Sprintf("[Connection] expected to read 4 bytes, only read: %d", count), nil)
			}
		}

		if err == nil && count != int(messageLength) {
			err = newClientError(fmt.Sprintf("[Connection] message length: %d, only read: %d", messageLength, count), nil)
		}

		if err == nil {
			return c.dataBuf, nil
		}

		if try < c.tempNetErrorRetries && isTemporaryNetError(err) {
			rt = b.Duration()
			try++
			logDebug("[Connection]", "temporary error, re-try %v, new read timeout: %v", try, rt)
		} else {
			c.setState(connInactive)
			return nil, err
		}
	}
}
638068
func (c *managedConnImpl) Read(b []byte) (n int, err error) {
	conn, err := c.rawConn()
	if err != nil {
		return 0, err
	}

	if c.options.ReadTimeout > 0 {
		deadline := c.options.getCurrentTime().Add(c.options.ReadTimeout)
		_ = conn.SetReadDeadline(deadline)
	}
	n, err = conn.Read(b)
	if err != nil {
		var localAddr string
		if conn.LocalAddr() != nil {
			localAddr = conn.LocalAddr().String()
		} else {
			localAddr = "(nil)"
		}

		var remoteAddr string
		if conn.RemoteAddr() != nil {
			remoteAddr = conn.RemoteAddr().String()
		} else {
			remoteAddr = "(nil)"
		}
		err = errors.Wrapf(err, "Read error from host: %s <-> %s", localAddr, remoteAddr)
	}
	return
}
1220868
func (c *I2PConn) Read(d []byte) (n int, err error) {
	n, err = c.c.Read(d)
	return
}
569069
func (c *PacketConn) Read(b []byte) (int, error) {
	bytesRead, _, err := c.ReadFrom(b)
	return bytesRead, err
}
903522
func (r *reader) Read(b []byte) (int, error) {
	n, err := r.r.Read(b)
	r.pos += int64(n)

	if err != nil && err != io.EOF {
		return n, err
	}

	q := readerReport{
		t:    time.Now(),
		pos:  r.pos,
		size: r.size,
		bps:  &r.bps,
	}

	select {
	case r.ch <- q:
	case <-r.ctx.Done():
	}

	return n, err
}