summaryrefslogtreecommitdiffstats
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorMartin Blais <blais@furius.ca>2006-05-26 12:03:27 (GMT)
committerMartin Blais <blais@furius.ca>2006-05-26 12:03:27 (GMT)
commit2856e5f3909f8366487ad85ca6c234040317e1e5 (patch)
tree7f2cbe99313c107ea133d08706171dd85683fe19 /Lib/socket.py
parent1b94940165b4e2b789855b24ea0297ebed691c46 (diff)
downloadcpython-2856e5f3909f8366487ad85ca6c234040317e1e5.zip
cpython-2856e5f3909f8366487ad85ca6c234040317e1e5.tar.gz
cpython-2856e5f3909f8366487ad85ca6c234040317e1e5.tar.bz2
Support for buffer protocol for socket and struct.
* Added socket.recv_buf() and socket.recvfrom_buf() methods, that use the buffer protocol (send and sendto already did). * Added struct.pack_to(), that is the corresponding buffer compatible method to unpack_from(). * Fixed minor typos in arraymodule.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 32a92b4..cc5e65e 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -140,7 +140,9 @@ class _socketobject(object):
__doc__ = _realsocket.__doc__
- __slots__ = ["_sock", "send", "recv", "sendto", "recvfrom",
+ __slots__ = ["_sock",
+ "recv", "recv_buf", "recvfrom_buf",
+ "send", "sendto", "recvfrom",
"__weakref__"]
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
@@ -149,8 +151,10 @@ class _socketobject(object):
self._sock = _sock
self.send = self._sock.send
self.recv = self._sock.recv
+ self.recv_buf = self._sock.recv_buf
self.sendto = self._sock.sendto
self.recvfrom = self._sock.recvfrom
+ self.recvfrom_buf = self._sock.recvfrom_buf
def close(self):
self._sock = _closedsocket()