bufsock module¶
socket or file wrapper provides buffered read and readto, among other methods.
Intended to deal intelligently with short reads. Also provides a rawio wrapper for os.open.
- class bufsock.bufsock(filedes, disable_flush=False, chunk_len=4096, maintain_alignment=False)[source]¶
Bases:
object
socket or file wrapper provides buffered read and readto, among other methods.
Intended to deal intelligently with short reads.
- readtomax(terminator, length)[source]¶
Read up to a specified terminator, or a maximum length, whichever comes first.
- recv(length=None)¶
Read some bytes.
- write(buf)¶
Send (write) some bytes.
- bufsock.o_binary()[source]¶
On platforms that have an os.O_BINARY, use it.
This includes CPython on Windows, and probably should include Jython on unix/linux but doesn’t (at least, not in Jython 2.5.2).
- class bufsock.rawio(filename=None, mode='r', perms=438, handle=None)[source]¶
Bases:
object
This class is a simple wrapper for os.open, os.read, os.write and os.close.
It should in turn allow us to wrap these os.* routines with bufsock. Alternatively, we should also be able to wrap a python file object with bufsock, but then you end up with two layers of buffering, each with slightly different functionality.
- open(filename=None, mode='r', perms=438, handle=None)¶
Initialize.