The IO layer makes the bottom of the RPyC stack. It deals with passing the data "on the wire".
Stream
Streams are an abstraction over files, sockets and pipes. The main difference is that streams are platform-agnostic and expose a consistent API that is required for the layers above.
API:
- close() - close the stream and release all OS resources
- closed - property, indicating whether the stream has been closed
- fileno() - returns the underlying file descriptor of the OS resource
- poll(timeout) - returns a boolean indicating whether the stream has data to read
- read(count) - reads 'count' bytes from the stream (blocking); will not return with less than 'count'. If EOF is encountered, closes the stream and raises EOFError
- write(data) - writes 'data' to the stream (blocking); will not return until all of 'data' is written. If an error occurs, closes the stream and raises EOFError
Channel
Channels operate over streams and provide framing over streams: unlike streams that read and write bytes, channels send and receive frames. Frames are made of a header and a payload and are dealt with as whole units. Because frames have a known size, the channel can compress these frames to improve network efficiency. Channels also provide thread-safely, by ensuring only one thread can access the underlying stream at every moment (so the frames are not interlaced and corrupted)1.
API:
- close() - close the stream and release all OS resources
- closed - property, indicating whether the stream has been closed
- fileno() - returns the underlying file descriptor of the OS resource
- poll(timeout) - returns a boolean indicating whether the stream has data to read
- recv() - returns the next frame's data (blocking)
- send(data) - sends the given data (string) as a frame (blocking)







