Receives the data from an incoming network transmission.
 Returns the binary string data received.
483178
def receive_transmission_data
      data = false
      response = IO.select([@session], nil, nil, @timeout)
      if response.nil?
        logger.error("No answer was received within the specified timeout period. Aborting.")
        stop_receiving
      else
        data = @session.recv(@max_receive_size)
      end
      data
    end
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()
922139
def dataReceived(self, data):
        
        self.connection._iobuf.write(data)
        self.connection.handle_read()
364927
def _receive_all(self):
        
        (data, part) = ('', '')
        if is_py3:
            crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding)
        else:
            crlf_bytes = self.__CRLF

        while self._running and part[-2:] != crlf_bytes:
            try:
                part = self._socket.recv(self.buffer_size)
            except (socket.timeout, socket.error) as e:
                if self._running:
                    self.stop()
                    raise SocketError('[Connect: %s]: Socket %s' % (self._unique_id, e))
                else:
                    return  # 133, prevents error if stop is called mid recv

            # an empty string indicates the server shutdown the socket
            if len(part) == 0:
                self.stop()
                raise SocketError('Connection closed by server')

            data += part.decode(self.__encoding)
        return data
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
682618
def data_received(self, data):
        
        self.logger.debug('Received data: %s', repr(data))

        try:
            request = self._parse_headers(data)
            self._handle_request(request)
        except InvalidRequestError as e:
            self._write_response(e.get_http_response())

        if not self.keepalive:
            if self._timeout_handle:
                self._timeout_handle.cancel()
            self.transport.close()

        if self._timeout and self._timeout_handle:
            self.logger.debug('Delaying timeout event')
            self._timeout_handle.cancel()
            self._timout_handle = self._loop.call_later(
                self._timeout, self._handle_timeout)
409354
def receive(self):
        
        while self.running:
            if self._receiver_lock.acquire(blocking=False):
                try:
                    raw = self.conn.recv()
                except WebSocketTimeoutException:
                    self._receiver_lock.release()
                    continue
                except WebSocketConnectionClosedException:
                    # this needs to restart the client, while keeping track
                    # of the currently subscribed channels!
                    self.conn = None
                    self._controller_q.put('restart')
                except AttributeError:
                    # self.conn is None, idle loop until shutdown of thread
                    self._receiver_lock.release()
                    continue
                msg = time.time(), json.loads(raw)
                log.debug("receiver Thread: Data Received: %s", msg)
                self.receiver_q.put(msg)
                self._receiver_lock.release()
            else:
                # The receiver_lock was locked, idling until available
                time.sleep(0.5)
173522
def read_exactly(socket, n):
    
    data = six.binary_type()
    while len(data) < n:
        next_data = read(socket, n - len(data))
        if not next_data:
            raise SocketError("Unexpected EOF")
        data += next_data
    return data
779512
def net_send(out_data, conn):
    '''  '''
    print('Sending {} bytes'.format(len(out_data)))
    conn.send(out_data)
28600
def send_and_receive_raw(self, target, lun, netfn, raw_bytes):
        
        return self._send_and_receive(target=target,
                                      lun=lun,
                                      netfn=netfn,
                                      cmdid=array('B', raw_bytes)[0],
                                      payload=raw_bytes[1:])
1340831
def received(self):
        
        if not hasattr(self, '_data'):
            # NB: units are reversed so that lowest numbered unit takes precedence
            self._data = JSONUnitDataView({key: value
                                           for unit in reversed(self)
                                           for key, value in unit.received_raw.items()})

        return self._data
221849
def net_recv(ws, conn):
    '''  '''
    in_data = conn.recv(RECEIVE_BYTES)
    if not in_data:
        # A receive of zero bytes indicates the TCP socket has been closed. We
        # need to pass None to wsproto to update its internal state.
        print('Received 0 bytes (connection closed)')
        ws.receive_data(None)
    else:
        print('Received {} bytes'.format(len(in_data)))
        ws.receive_data(in_data)
1145358
async def receive(self, pkt):
        """"""
        self.server.logger.info('%s: Received packet %s data %s',
                                self.sid, packet.packet_names[pkt.packet_type],
                                pkt.data if not isinstance(pkt.data, bytes)
                                else '<binary>')
        if pkt.packet_type == packet.PING:
            self.last_ping = time.time()
            await self.send(packet.Packet(packet.PONG, pkt.data))
        elif pkt.packet_type == packet.MESSAGE:
            await self.server._trigger_event(
                'message', self.sid, pkt.data,
                run_async=self.server.async_handlers)
        elif pkt.packet_type == packet.UPGRADE:
            await self.send(packet.Packet(packet.NOOP))
        elif pkt.packet_type == packet.CLOSE:
            await self.close(wait=False, abort=True)
        else:
            raise exceptions.UnknownPacketError()
44384
def recvData(peer)
      msg = nil

      @logger.debug "Got data from peer #{peer}"

      if peer.state == :handshaking
        # Read handshake message
        begin
          @logger.debug "Reading handshake from #{peer}"
          msg = PeerHandshake.unserializeFrom currentIo
        rescue
          @logger.warn "Peer #{peer} failed handshake: #{$!}"
          setPeerDisconnected(peer)
          close
          return
        end
      else
        begin
          @logger.debug "Reading wire-message from #{peer}"
          msg = peer.peerMsgSerializer.unserializeFrom currentIo
          #msg = PeerWireMessage.unserializeFrom currentIo
        rescue EOFError
          @logger.info "Peer #{peer} disconnected."
          setPeerDisconnected(peer)
          close
          return
        rescue
          @logger.warn "Unserializing message from peer #{peer} failed: #{$!}"
          @logger.warn $!.backtrace.join "\n"
          setPeerDisconnected(peer)
          close
          return
        end

        peer.updateUploadRate msg
        torrentData = @torrentData[peer.infoHash]
        torrentData.bytesDownloaded += msg.length if torrentData
        @logger.debug "Peer #{peer} upload rate: #{peer.uploadRate.value}  data only: #{peer.uploadRateDataOnly.value}"
      end


      if msg.is_a? PeerHandshake
        # This is a remote peer that we connected to returning our handshake.
        processHandshake(msg, peer)
        peer.state = :established
        peer.amChoked = true
        peer.peerChoked = true
        peer.amInterested = false
        peer.peerInterested = false
      elsif msg.is_a? BitfieldMessage
        @logger.debug "Received bitfield message from peer."
        handleBitfield(msg, peer)
      elsif msg.is_a? Unchoke
        @logger.debug "Received unchoke message from peer."
        peer.amChoked = false
      elsif msg.is_a? Choke
        @logger.debug "Received choke message from peer."
        peer.amChoked = true
      elsif msg.is_a? Interested
        @logger.debug "Received interested message from peer."
        peer.peerInterested = true
      elsif msg.is_a? Uninterested
        @logger.debug "Received uninterested message from peer."
        peer.peerInterested = false
      elsif msg.is_a? Piece
        @logger.debug "Received piece message from peer for torrent #{QuartzTorrent.bytesToHex(peer.infoHash)}: piece #{msg.pieceIndex} offset #{msg.blockOffset} length #{msg.data.length}."
        handlePieceReceive(msg, peer)
      elsif msg.is_a? Request
        @logger.debug "Received request message from peer for torrent #{QuartzTorrent.bytesToHex(peer.infoHash)}: piece #{msg.pieceIndex} offset #{msg.blockOffset} length #{msg.blockLength}."
        handleRequest(msg, peer)
      elsif msg.is_a? Have
        @logger.debug "Received have message from peer for torrent #{QuartzTorrent.bytesToHex(peer.infoHash)}: piece #{msg.pieceIndex}"
        handleHave(msg, peer)
      elsif msg.is_a? KeepAlive
        @logger.debug "Received keep alive message from peer."
      elsif msg.is_a? ExtendedHandshake
        @logger.debug "Received extended handshake message from peer."
        handleExtendedHandshake(msg, peer)
      elsif msg.is_a? ExtendedMetaInfo
        @logger.debug "Received extended metainfo message from peer."
        handleExtendedMetainfo(msg, peer)
      else
        @logger.warn "Received a #{msg.class} message but handler is not implemented"
      end
    end
856169
def get_data(self):
        ''' 
        '''
        fifo_size = self._intf._get_tcp_data_size()
        fifo_int_size = int((fifo_size - (fifo_size % 4)) / 4)
        data = self._intf._get_tcp_data(fifo_int_size * 4)
        return np.frombuffer(data, dtype=np.dtype('<u4'))
249888
def receive(self):
        """"""
        while True:
            try:
                # read data from the buffer
                data = self.socket.recv(self._socket_recv)
            except socket.timeout as e:
                _LOGGER.debug(e)
                sleep(1)
                return
            except socket.error as e:
                # Something else happened
                _LOGGER.error(e)
                return

            else:
                if len(data) == 0:
                    # no more data being transmitted
                    _LOGGER.info('orderly shutdown on server end')
                    return

                # remove trailing carriage return, then split
                # on carriage return (for multi-line replies)
                results = data.decode('ascii').rstrip('\r').split('\r')
                if len(results) > 1:
                    _LOGGER.debug("multi-line reply")
                for result in results:
                    _LOGGER.debug("receive thread: " + result)
                    self.queue.put(result)
557713
def data_received(self, data):
        
        self.time_out_handle.cancel()
        self.session.update(data.decode())

        if self.session.state == STATE_STARTING:
            self.transport.write(self.method.message.encode())
            self.time_out_handle = self.loop.call_later(
                TIME_OUT_LIMIT, self.time_out)

        elif self.session.state == STATE_PLAYING:
            self.callback(SIGNAL_PLAYING)

            if self.session.session_timeout != 0:
                interval = self.session.session_timeout - 5
                self.loop.call_later(interval, self.keep_alive)

        else:
            self.stop()