summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2007-03-18 08:26:23 (GMT)
committerGeorg Brandl <georg@python.org>2007-03-18 08:26:23 (GMT)
commitc77f6c6ea4670bec31213023384ba6b051a09b44 (patch)
tree9336aabecd5dc205b03f1a9aae3e142100a6ebe5
parent8e92dd0c9cba20d7f2532f613d5f419931733e0b (diff)
downloadcpython-c77f6c6ea4670bec31213023384ba6b051a09b44.zip
cpython-c77f6c6ea4670bec31213023384ba6b051a09b44.tar.gz
cpython-c77f6c6ea4670bec31213023384ba6b051a09b44.tar.bz2
Backport docs for recv_into and recvfrom_into.
-rw-r--r--Doc/lib/libsocket.tex22
-rw-r--r--Doc/whatsnew/whatsnew25.tex4
2 files changed, 24 insertions, 2 deletions
diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex
index f510fd4..e5a3c32 100644
--- a/Doc/lib/libsocket.tex
+++ b/Doc/lib/libsocket.tex
@@ -574,6 +574,28 @@ same meaning as for \method{recv()} above.
(The format of \var{address} depends on the address family --- see above.)
\end{methoddesc}
+\begin{methoddesc}[socket]{recvfrom_into}{buffer\optional{, nbytes\optional{, flags}}}
+Receive data from the socket, writing it into \var{buffer} instead of
+creating a new string. The return value is a pair
+\code{(\var{nbytes}, \var{address})} where \var{nbytes} is the number
+of bytes received and \var{address} is the address of the socket
+sending the data. See the \UNIX{} manual page
+\manpage{recv}{2} for the meaning of the optional argument
+\var{flags}; it defaults to zero. (The format of \var{address}
+depends on the address family --- see above.)
+\versionadded{2.5}
+\end{methoddesc}
+
+\begin{methoddesc}[socket]{recv_into}{buffer\optional{, nbytes\optional{, flags}}}
+Receive up to \var{nbytes} bytes from the socket,
+storing the data into a buffer rather than creating a new string.
+If \var{nbytes} is not specified (or 0),
+receive up to the size available in the given buffer.
+See the \UNIX{} manual page \manpage{recv}{2} for the meaning of the
+optional argument \var{flags}; it defaults to zero.
+\versionadded{2.5}
+\end{methoddesc}
+
\begin{methoddesc}[socket]{send}{string\optional{, flags}}
Send data to the socket. The socket must be connected to a remote
socket. The optional \var{flags} argument has the same meaning as for
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index fce3927..85d5a2a 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -1704,8 +1704,8 @@ article about them is at \url{http://www.linuxjournal.com/article/7356}.
In Python code, netlink addresses are represented as a tuple of 2 integers,
\code{(\var{pid}, \var{group_mask})}.
-Two new methods on socket objects, \method{recv_buf(\var{buffer})} and
-\method{recvfrom_buf(\var{buffer})}, store the received data in an object
+Two new methods on socket objects, \method{recv_into(\var{buffer})} and
+\method{recvfrom_into(\var{buffer})}, store the received data in an object
that supports the buffer protocol instead of returning the data as a
string. This means you can put the data directly into an array or a
memory-mapped file.