Receive data from the socket. The return value is a string
        representing the data received. The amount of data may be less than the
        ammount specified by _bufsize_.
484210
def recv(self, bufsize, **kws):
        
        return Recv(self, bufsize, timeout=self._timeout, **kws)
679700
def _read_socket(self):
        
        while True:
            base_bytes = self._socket.recv(BASE_SIZE)
            base = basemessage.parse(base_bytes)
            payload_bytes = self._socket.recv(base.payload_length)
            self._handle_message(packet.parse(base_bytes + payload_bytes))
286414
def __recieve_tcp_data(self, data_recv, size):
        
        data = []
        tcp_length = self.__test_tcp_top(data_recv)
        if self.verbose: print ("tcp_length {}, size {}".format(tcp_length, size))
        if tcp_length <= 0:
            if self.verbose: print ("Incorrect tcp packet")
            return None, b""
        if (tcp_length - 8) < size:
            if self.verbose: print ("tcp length too small... retrying")
            resp, bh = self.__recieve_tcp_data(data_recv, tcp_length - 8)
            data.append(resp)
            size -= len(resp)
            if self.verbose: print ("new tcp DATA packet to fill misssing {}".format(size))
            data_recv = bh + self.__sock.recv(size + 16 )
            if self.verbose: print ("new tcp DATA starting with {} bytes".format(len(data_recv)))
            resp, bh = self.__recieve_tcp_data(data_recv, size)
            data.append(resp)
            if self.verbose: print ("for misssing {} recieved {} with extra {}".format(size, len(resp), len(bh)))
            return b''.join(data), bh
        recieved = len(data_recv)
        if self.verbose: print ("recieved {}, size {}".format(recieved, size))
        response = unpack('HHHH', data_recv[8:16])[0]
        if recieved >= (size + 32):
            if response == const.CMD_DATA:
                resp = data_recv[16 : size + 16]
                if self.verbose: print ("resp complete len {}".format(len(resp)))
                return resp, data_recv[size + 16:]
            else:
                if self.verbose: print("incorrect response!!! {}".format(response))
                return None, b""
        else:
            if self.verbose: print ("try DATA incomplete (actual valid {})".format(recieved-16))
            data.append(data_recv[16 : size + 16 ])
            size -= recieved - 16
            broken_header = b""
            if size < 0:
                broken_header = data_recv[size:]
                if self.verbose: print ("broken", (broken_header).encode('hex'))
            if size > 0:
                data_recv = self.__recieve_raw_data(size)
                data.append(data_recv)
            return b''.join(data), broken_header
236548
def _receive_data(data)
      if data[0..6] == 'ANSWER '
        lf = data.index("\n") + 1
        lflf = data.index("\n\n", lf) - 1
        data = data[lf..lflf]
        data = Oj.load(data, :mode => :compat)
      end
      data
    end
591856
private void receive() {
    try {
      Socket socket = null;
      BufferedReader reader = null;
      try {
        // connect to the server
        socket = new Socket(host, port);
        reader = new BufferedReader(
            new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
        // Until stopped or connection broken continue reading
        String userInput;
        while (!isStopped() && (userInput = reader.readLine()) != null) {
          System.out.println("Received data '" + userInput + "'");
          store(userInput);
        }
      } finally {
        Closeables.close(reader, /* swallowIOException = */ true);
        Closeables.close(socket,  /* swallowIOException = */ true);
      }
      // Restart in an attempt to connect again when server is active again
      restart("Trying to connect again");
    } catch(ConnectException ce) {
      // restart if could not connect to server
      restart("Could not connect", ce);
    } catch(Throwable t) {
      restart("Error receiving data", t);
    }
  }
1181096
def receive_data(self):  # pragma: no cover; no covered since qt event loop
        ''' 
        '''
        while(not self._stop_readout.wait(0.01)):  # use wait(), do not block
            if self._send_data:
                if self.socket_type != zmq.DEALER:
                    raise RuntimeError('You send data without a bidirectional '
                                       'connection! Define a bidirectional '
                                       'connection.')
                self.receiver.send(self._send_data)
                self._send_data = None
            try:
                data_serialized = self.receiver.recv(flags=zmq.NOBLOCK)
                data = self.deserializer(data_serialized)
                self.data.emit(data)
            except zmq.Again:
                pass
        self.finished.emit()
669049
def data_received(self, data):
        
        # DIY line buffering...
        newline = b'\r\n'
        eot = b'\x04'
        self._readbuf += data
        while newline in self._readbuf:
            line, _, self._readbuf = self._readbuf.partition(newline)
            if line:
                if eot in line:
                    # Discard everything before EOT
                    _, _, line = line.partition(eot)
                try:
                    decoded = line.decode('ascii')
                except UnicodeDecodeError:
                    _LOGGER.debug("Invalid data received, ignoring...")
                    return
                self.line_received(decoded)
1141795
def Recv(self):
    
    size = struct.unpack(_STRUCT_FMT, self._ReadN(_STRUCT_LEN))[0]
    if size > MAX_SIZE:
      raise ProtocolError("Expected size to be at most %d, got %d" % (MAX_SIZE,
                                                                      size))
    with self._read_lock:
      buf = self._ReadN(size)
      self._ReadMagic()

    res = common_pb2.Message()
    res.ParseFromString(buf)

    return res, len(buf)
992023
def mock_server_receive(sock, length):
    """"""
    msg = b''
    while length:
        chunk = sock.recv(length)
        if chunk == b'':
            raise socket.error(errno.ECONNRESET, 'closed')

        length -= len(chunk)
        msg += chunk

    return msg
310961
def receive(max_len=nil)
      max_len ||= 1024

      begin
        data = @socket.recv(max_len)
      rescue IO::WaitReadable
        @logger.logv 'Retrying receive...'
        IO.select([@socket])
        retry
      rescue Exception => e
        if e.class != 'IOError' && e.message != 'closed stream'
          @logger.log_exception(e, 'EXCEPTION during receive!')
        end
      end

      if (data.nil? || data.empty?)
        @logger.log "Client #{@socket.inspect} disconnected!"
        data = ''
      else
        @logger.log "Received #{data.length} bytes"
      end

      return data
    end
829639
def receive():
    
    header = _in_file.read(8)
    logging.getLogger(__name__).debug('Received command, header: [%s]' % header)
    if header is None or len(header) < 8:
        # Pipe EOF encountered
        logging.getLogger(__name__).debug('Pipe EOF encountered')
        return None, None
    length = int(header[2:])
    data = _in_file.read(length)
    command = CommandType(header[:2])
    data = data.decode('utf8')
    logging.getLogger(__name__).debug('Received command, data: [%s]' % data)
    return command, data
1321489
def _read(self):
        
        line = ''
        finished = False
        while not finished:
            char = self._socket.recv(1)
            if char == '':
                return ''
            elif char == '\r':
                continue
            elif char == '\n':
                finished = True
                continue
            else:
                line = line + char
        logger.debug('Server sent: ' + line.rstrip())
        return line
119901
def receive(new_data)
      return if @state == :closed
      return if new_data.empty?
      @buffer << new_data
      consume_buffer
    rescue RemoteConnectionError => e
      callback(:connection_error, e)
      goaway(e.http2_error_type)
      close
    end
1015530
private ByteBuffer recv(int attempt)
          throws IOException, SocketException, SocketTimeoutException {
    int timeout = UDP_BASE_TIMEOUT_SECONDS * (int) Math.pow(2, attempt);
    logger.trace("Setting receive timeout to {}s for attempt {}...",
            timeout, attempt);
    this.socket.setSoTimeout(timeout * 1000);

    try {
      DatagramPacket p = new DatagramPacket(
              new byte[UDP_PACKET_LENGTH],
              UDP_PACKET_LENGTH);
      this.socket.receive(p);
      return ByteBuffer.wrap(p.getData(), 0, p.getLength());
    } catch (SocketTimeoutException ste) {
      throw ste;
    }
  }
828507
def receive_data(data)
      @data << data

      return unless data.index("\n\n")
      begin
        result = _receive_data(@data)
      rescue
        raise
        result = nil
      end
      @callback.call(!result.nil?, result) unless @callback.nil?
      @callback = nil
      @available = true
    end
1077654
def _recv(self, max_size):
        
        # wait for read
        if not self._can_read():
            self.close()
            return None
        # recv
        try:
            r_buffer = self.__sock.recv(max_size)
        except socket.error:
            r_buffer = None
        # handle recv error
        if not r_buffer:
            self.__last_error = const.MB_RECV_ERR
            self.__debug_msg('_recv error')
            self.close()
            return None
        return r_buffer
884552
def SafeReadBytes(self, length):
        
        data = self.ReadBytes(length)
        if len(data) < length:
            raise ValueError("Not enough data available")
        else:
            return data