bufsock.py is a python module that makes it a little bit easier to work
with sockets, and may also make your I/O faster if you're reading and/or
writing lots of tiny packets.
Also, you may find that it makes your network applications more reliable, as the network is allowed to split apart your packets into multiple smaller packets, or aggregate two or more packets into one larger packet, if it decides it needs to do so for reliability or performance. So you might do a s.recv expecting to get one line of input, but the network decided to batch together two remote s.send's into one s.recv, for example. But the network usually, but not always, will batch up your packets the way you'd expect - so this can be a difficult (and surprising) problem to track down.
You check it out here.
It supports the following methods:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((hostname, port)) bs = bufsock.bufsock(sock) version = bs.readto('\n') print(version)
You can e-mail the author with questions or comments: