Module | Kgio::PipeMethods |
In: |
ext/kgio/accept.c
(CVS)
|
This module may be used used to create classes that respond to various Kgio methods for reading and writing. This is included in Kgio::Pipe by default.
io.kgio_read(maxlen) -> buffer io.kgio_read(maxlen, buffer) -> buffer
Reads at most maxlen bytes from the stream socket. Returns with a newly allocated buffer, or may reuse an existing buffer if supplied.
This may block and call any method defined to kgio_wait_readable for the class.
Returns nil on EOF.
This behaves like read(2) and IO#readpartial, NOT fread(3) or IO#read which possess read-in-full behavior.
Same as Kgio::PipeMethods#kgio_read, except EOFError is raised on EOF without a backtrace. This method is intended as a drop-in replacement for places where IO#readpartial is used, and may be aliased as such.
io.kgio_tryread(maxlen) -> buffer io.kgio_tryread(maxlen, buffer) -> buffer
Reads at most maxlen bytes from the stream socket. Returns with a newly allocated buffer, or may reuse an existing buffer if supplied.
Returns nil on EOF.
Returns :wait_readable if EAGAIN is encountered.
io.kgio_trywrite(str) -> nil, String or :wait_writable
Returns nil if the write was completed in full.
Returns a String containing the unwritten portion if EAGAIN was encountered, but some portion was successfully written.
Returns :wait_writable if EAGAIN is encountered and nothing was written.
io.kgio_trywritev(array) -> nil, Array or :wait_writable
Returns nil if the write was completed in full.
Returns an Array of strings containing the unwritten portion if EAGAIN was encountered, but some portion was successfully written.
Returns :wait_writable if EAGAIN is encountered and nothing was written.
Note: it uses +Array()+ semantic for converting argument, so that it will succeed if you pass something else.