Method: Usbmux::SafeStreamSocket#receive

Defined in:
lib/usbmux/usbmux.rb

#receive(size) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/usbmux/usbmux.rb', line 28

def receive(size)
  message = ''
  while message.length < size
    chunk = @sock.recv(size - message.length)
    if chunk.empty?
      raise MuxError.new('Socket connection broken')
    end
    message = message + chunk
  end
  message
end