Method: TCPSocket#readpartial
- Defined in:
- lib/polyphony/extensions/socket.rb
#readpartial(maxlen, buf = +'',, buffer_pos = 0, raise_on_eof = true) ⇒ String?
Reads up to maxlen from the socket. If buf is given, it is used as the
buffer to read into, otherwise a new string is allocated. If buffer_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 raise_on_eof is true (the default,) an EOFError will be
raised on EOF, otherwise nil will be returned.
If no bytes are available and EOF is not hit, this method will block until
the socket is ready to read from.
409 410 411 412 413 414 |
# File 'lib/polyphony/extensions/socket.rb', line 409 def readpartial(maxlen, buf = +'', buffer_pos = 0, raise_on_eof = true) result = Polyphony.backend_recv(self, buf, maxlen, buffer_pos) raise EOFError if !result && raise_on_eof result end |