lib/polyphony/extensions/socket.rb
# call-seq:
#   socket.read -> string
#   socket.read(maxlen) -> string
#   socket.read(maxlen, buf) -> buf
#   socket.read(maxlen, buf, buf_pos) -> buf
#
# Reads from the socket. If `maxlen` is given, reads up to `maxlen` bytes from
# the socket, otherwise reads to `EOF`. If `buf` is given, it is used as the
# buffer to read into, otherwise a new string is allocated. If `buf_pos` is
# given, reads into the given offset (in bytes) in the given buffer. If the
# given buffer offset is negative, it is calculated from the current end of
# the buffer (`-1` means the read data will be appended to the end of the
# buffer).
#
# If no bytes are available and `EOF` is not hit, this method will block until
# the socket is ready to read from.
#
# @param maxlen [Integer, nil] maximum bytes to read from socket
# @param buf [String, nil] buffer to read into
# @param buf_pos [Number] buffer position to read into
# @return [String] buffer used for reading


Reads from the socket.

If no bytes are available and `EOF` is not hit, this method will block until
the socket is ready to read from.
Reads from the socket . If no bytes are available and ` EOF ` is not hit this method will block until the socket is ready to read from .
def read(maxlen = nil, buf = nil, buf_pos = 0)
    return Polyphony.backend_recv(self, buf, maxlen, buf_pos) if buf
    return Polyphony.backend_recv(self, +'', maxlen, 0) if maxlen
    buf = +''
    len = buf.bytesize
    while true
      Polyphony.backend_recv(self, buf, maxlen || 4096, -1)
      new_len = buf.bytesize
      break if new_len == len
      len = new_len
    end
    buf
  end
def read ( maxlen = nil , buf = nil , buf_pos = 0 ) return Polyphony . backend_recv ( self , buf , maxlen , buf_pos ) if buf return Polyphony . backend_recv ( self , + '' , maxlen , 0 ) if maxlen buf = + '' len = buf . bytesize while true Polyphony . backend_recv ( self , buf , maxlen || 4096 , - 1 ) new_len = buf . bytesize break if new_len == len len = new_len end buf end
call-seq:
socket.read -> string
socket.read(maxlen) -> string
socket.read(maxlen, buf) -> buf
socket.read(maxlen, buf, buf_pos) -> buf
call - seq : socket . read - > string socket . read ( maxlen ) - > string socket . read ( maxlen buf ) - > buf socket . read ( maxlen buf buf_pos ) - > buf
buffer used for reading
buffer used for reading
String
maxlen
maximum bytes to read from socket
maximum bytes to read from socket
buf
buffer to read into
buffer to read into
buf_pos
buffer position to read into
buffer position to read into