readFromSocket method

int readFromSocket(
  1. RawSocket socket,
  2. int count
)

Reads up to count bytes from the socket into the buffer. Returns the number of bytes read.

Implementation

int readFromSocket(RawSocket socket, int count) {
  final bytes = socket.read(count)?.toList();
  if (bytes == null) return 0;

  var bytesRead = bytes.length;
  _list.setRange(_writePos, _writePos + bytesRead, bytes);
  _writePos += bytesRead;
  return bytesRead;
}