Use {methoddesc} as appropriate.

This commit is contained in:
Fred Drake 1998-04-03 07:04:45 +00:00
parent 5dabeed4ea
commit 3f1c4720b5
2 changed files with 74 additions and 76 deletions

View File

@ -189,60 +189,59 @@ Socket objects have the following methods. Except for
\method{makefile()} these correspond to \UNIX{} system calls \method{makefile()} these correspond to \UNIX{} system calls
applicable to sockets. applicable to sockets.
\setindexsubitem{(socket method)} \begin{methoddesc}[socket]{accept}{}
\begin{funcdesc}{accept}{}
Accept a connection. Accept a connection.
The socket must be bound to an address and listening for connections. The socket must be bound to an address and listening for connections.
The return value is a pair \code{(\var{conn}, \var{address})} The return value is a pair \code{(\var{conn}, \var{address})}
where \var{conn} is a \emph{new} socket object usable to send and where \var{conn} is a \emph{new} socket object usable to send and
receive data on the connection, and \var{address} is the address bound receive data on the connection, and \var{address} is the address bound
to the socket on the other end of the connection. to the socket on the other end of the connection.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{bind}{address} \begin{methoddesc}[socket]{bind}{address}
Bind the socket to \var{address}. The socket must not already be bound. Bind the socket to \var{address}. The socket must not already be bound.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{close}{} \begin{methoddesc}[socket]{close}{}
Close the socket. All future operations on the socket object will fail. Close the socket. All future operations on the socket object will fail.
The remote end will receive no more data (after queued data is flushed). The remote end will receive no more data (after queued data is flushed).
Sockets are automatically closed when they are garbage-collected. Sockets are automatically closed when they are garbage-collected.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{connect}{address} \begin{methoddesc}[socket]{connect}{address}
Connect to a remote socket at \var{address}. Connect to a remote socket at \var{address}.
(The format of \var{address} depends on the address family --- see (The format of \var{address} depends on the address family --- see
above.) above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{connect_ex}{address} \begin{methoddesc}[socket]{connect_ex}{address}
Like \code{connect(\var{address})}, but return an error indicator Like \code{connect(\var{address})}, but return an error indicator
instead of raising an exception. The error indicator is 0 if the instead of raising an exception. The error indicator is 0 if the
operation succeeded, otherwise the value of the \cdata{errno} operation succeeded, otherwise the value of the \cdata{errno}
variable. This is useful e.g. for asynchronous connects. variable. This is useful, e.g., for asynchronous connects.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{fileno}{} \begin{methoddesc}[socket]{fileno}{}
Return the socket's file descriptor (a small integer). This is useful Return the socket's file descriptor (a small integer). This is useful
with \function{select.select()}. with \function{select.select()}.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getpeername}{} \begin{methoddesc}[socket]{getpeername}{}
Return the remote address to which the socket is connected. This is Return the remote address to which the socket is connected. This is
useful to find out the port number of a remote IP socket, for instance. useful to find out the port number of a remote IP socket, for instance.
(The format of the address returned depends on the address family --- (The format of the address returned depends on the address family ---
see above.) On some systems this function is not supported. see above.) On some systems this function is not supported.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getsockname}{} \begin{methoddesc}[socket]{getsockname}{}
Return the socket's own address. This is useful to find out the port Return the socket's own address. This is useful to find out the port
number of an IP socket, for instance. number of an IP socket, for instance.
(The format of the address returned depends on the address family --- (The format of the address returned depends on the address family ---
see above.) see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getsockopt}{level, optname\optional{, buflen}} \begin{methoddesc}[socket]{getsockopt}{level, optname\optional{, buflen}}
Return the value of the given socket option (see the \UNIX{} man page Return the value of the given socket option (see the \UNIX{} man page
\manpage{getsockopt}{2}). The needed symbolic constants \manpage{getsockopt}{2}). The needed symbolic constants
(\constant{SO_*} etc.) are defined in this module. If \var{buflen} (\constant{SO_*} etc.) are defined in this module. If \var{buflen}
@ -252,15 +251,15 @@ the maximum length of the buffer used to receive the option in, and
this buffer is returned as a string. It is up to the caller to decode this buffer is returned as a string. It is up to the caller to decode
the contents of the buffer (see the optional built-in module the contents of the buffer (see the optional built-in module
\module{struct} for a way to decode C structures encoded as strings). \module{struct} for a way to decode C structures encoded as strings).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{listen}{backlog} \begin{methoddesc}[socket]{listen}{backlog}
Listen for connections made to the socket. The \var{backlog} argument Listen for connections made to the socket. The \var{backlog} argument
specifies the maximum number of queued connections and should be at specifies the maximum number of queued connections and should be at
least 1; the maximum value is system-dependent (usually 5). least 1; the maximum value is system-dependent (usually 5).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{makefile}{\optional{mode\optional{, bufsize}}} \begin{methoddesc}[socket]{makefile}{\optional{mode\optional{, bufsize}}}
Return a \dfn{file object} associated with the socket. (File objects Return a \dfn{file object} associated with the socket. (File objects
were described earlier in \ref{bltin-file-objects}, ``File Objects.'') were described earlier in \ref{bltin-file-objects}, ``File Objects.'')
The file object references a \cfunction{dup()}ped version of the The file object references a \cfunction{dup()}ped version of the
@ -268,49 +267,49 @@ socket file descriptor, so the file object and socket object may be
closed or garbage-collected independently. The optional \var{mode} closed or garbage-collected independently. The optional \var{mode}
and \var{bufsize} arguments are interpreted the same way as by the and \var{bufsize} arguments are interpreted the same way as by the
built-in \function{open()} function. built-in \function{open()} function.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{recv}{bufsize\optional{, flags}} \begin{methoddesc}[socket]{recv}{bufsize\optional{, flags}}
Receive data from the socket. The return value is a string representing Receive data from the socket. The return value is a string representing
the data received. The maximum amount of data to be received the data received. The maximum amount of data to be received
at once is specified by \var{bufsize}. See the \UNIX{} manual page at once is specified by \var{bufsize}. See the \UNIX{} manual page
\manpage{recv}{2} for the meaning of the optional argument \manpage{recv}{2} for the meaning of the optional argument
\var{flags}; it defaults to zero. \var{flags}; it defaults to zero.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{recvfrom}{bufsize\optional{, flags}} \begin{methoddesc}[socket]{recvfrom}{bufsize\optional{, flags}}
Receive data from the socket. The return value is a pair Receive data from the socket. The return value is a pair
\code{(\var{string}, \var{address})} where \var{string} is a string \code{(\var{string}, \var{address})} where \var{string} is a string
representing the data received and \var{address} is the address of the representing the data received and \var{address} is the address of the
socket sending the data. The optional \var{flags} argument has the socket sending the data. The optional \var{flags} argument has the
same meaning as for \method{recv()} above. same meaning as for \method{recv()} above.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{send}{string\optional{, flags}} \begin{methoddesc}[socket]{send}{string\optional{, flags}}
Send data to the socket. The socket must be connected to a remote 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 socket. The optional \var{flags} argument has the same meaning as for
\method{recv()} above. Returns the number of bytes sent. \method{recv()} above. Returns the number of bytes sent.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{sendto}{string\optional{, flags}, address} \begin{methoddesc}[socket]{sendto}{string\optional{, flags}, address}
Send data to the socket. The socket should not be connected to a Send data to the socket. The socket should not be connected to a
remote socket, since the destination socket is specified by remote socket, since the destination socket is specified by
\var{address}. The optional \var{flags} argument has the same \var{address}. The optional \var{flags} argument has the same
meaning as for \method{recv()} above. Return the number of bytes sent. meaning as for \method{recv()} above. Return the number of bytes sent.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{setblocking}{flag} \begin{methoddesc}[socket]{setblocking}{flag}
Set blocking or non-blocking mode of the socket: if \var{flag} is 0, Set blocking or non-blocking mode of the socket: if \var{flag} is 0,
the socket is set to non-blocking, else to blocking mode. Initially the socket is set to non-blocking, else to blocking mode. Initially
all sockets are in blocking mode. In non-blocking mode, if a all sockets are in blocking mode. In non-blocking mode, if a
\method{recv()} call doesn't find any data, or if a \code{send} call can't \method{recv()} call doesn't find any data, or if a \code{send} call can't
immediately dispose of the data, a \exception{error} exception is immediately dispose of the data, a \exception{error} exception is
raised; in blocking mode, the calls block until they can proceed. raised; in blocking mode, the calls block until they can proceed.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{setsockopt}{level, optname, value} \begin{methoddesc}[socket]{setsockopt}{level, optname, value}
Set the value of the given socket option (see the \UNIX{} man page Set the value of the given socket option (see the \UNIX{} man page
\manpage{setsockopt}{2}). The needed symbolic constants are defined in \manpage{setsockopt}{2}). The needed symbolic constants are defined in
the \module{socket} module (\code{SO_*} etc.). The value can be an the \module{socket} module (\code{SO_*} etc.). The value can be an
@ -319,14 +318,14 @@ up to the caller to ensure that the string contains the proper bits
(see the optional built-in module (see the optional built-in module
\module{struct}\refbimodindex{struct} for a way to encode C structures \module{struct}\refbimodindex{struct} for a way to encode C structures
as strings). as strings).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{shutdown}{how} \begin{methoddesc}[socket]{shutdown}{how}
Shut down one or both halves of the connection. If \var{how} is Shut down one or both halves of the connection. If \var{how} is
\code{0}, further receives are disallowed. If \var{how} is \code{1}, \code{0}, further receives are disallowed. If \var{how} is \code{1},
further sends are disallowed. If \var{how} is \code{2}, further sends further sends are disallowed. If \var{how} is \code{2}, further sends
and receives are disallowed. and receives are disallowed.
\end{funcdesc} \end{methoddesc}
Note that there are no methods \method{read()} or \method{write()}; Note that there are no methods \method{read()} or \method{write()};
use \method{recv()} and \method{send()} without \var{flags} argument use \method{recv()} and \method{send()} without \var{flags} argument

View File

@ -189,60 +189,59 @@ Socket objects have the following methods. Except for
\method{makefile()} these correspond to \UNIX{} system calls \method{makefile()} these correspond to \UNIX{} system calls
applicable to sockets. applicable to sockets.
\setindexsubitem{(socket method)} \begin{methoddesc}[socket]{accept}{}
\begin{funcdesc}{accept}{}
Accept a connection. Accept a connection.
The socket must be bound to an address and listening for connections. The socket must be bound to an address and listening for connections.
The return value is a pair \code{(\var{conn}, \var{address})} The return value is a pair \code{(\var{conn}, \var{address})}
where \var{conn} is a \emph{new} socket object usable to send and where \var{conn} is a \emph{new} socket object usable to send and
receive data on the connection, and \var{address} is the address bound receive data on the connection, and \var{address} is the address bound
to the socket on the other end of the connection. to the socket on the other end of the connection.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{bind}{address} \begin{methoddesc}[socket]{bind}{address}
Bind the socket to \var{address}. The socket must not already be bound. Bind the socket to \var{address}. The socket must not already be bound.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{close}{} \begin{methoddesc}[socket]{close}{}
Close the socket. All future operations on the socket object will fail. Close the socket. All future operations on the socket object will fail.
The remote end will receive no more data (after queued data is flushed). The remote end will receive no more data (after queued data is flushed).
Sockets are automatically closed when they are garbage-collected. Sockets are automatically closed when they are garbage-collected.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{connect}{address} \begin{methoddesc}[socket]{connect}{address}
Connect to a remote socket at \var{address}. Connect to a remote socket at \var{address}.
(The format of \var{address} depends on the address family --- see (The format of \var{address} depends on the address family --- see
above.) above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{connect_ex}{address} \begin{methoddesc}[socket]{connect_ex}{address}
Like \code{connect(\var{address})}, but return an error indicator Like \code{connect(\var{address})}, but return an error indicator
instead of raising an exception. The error indicator is 0 if the instead of raising an exception. The error indicator is 0 if the
operation succeeded, otherwise the value of the \cdata{errno} operation succeeded, otherwise the value of the \cdata{errno}
variable. This is useful e.g. for asynchronous connects. variable. This is useful, e.g., for asynchronous connects.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{fileno}{} \begin{methoddesc}[socket]{fileno}{}
Return the socket's file descriptor (a small integer). This is useful Return the socket's file descriptor (a small integer). This is useful
with \function{select.select()}. with \function{select.select()}.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getpeername}{} \begin{methoddesc}[socket]{getpeername}{}
Return the remote address to which the socket is connected. This is Return the remote address to which the socket is connected. This is
useful to find out the port number of a remote IP socket, for instance. useful to find out the port number of a remote IP socket, for instance.
(The format of the address returned depends on the address family --- (The format of the address returned depends on the address family ---
see above.) On some systems this function is not supported. see above.) On some systems this function is not supported.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getsockname}{} \begin{methoddesc}[socket]{getsockname}{}
Return the socket's own address. This is useful to find out the port Return the socket's own address. This is useful to find out the port
number of an IP socket, for instance. number of an IP socket, for instance.
(The format of the address returned depends on the address family --- (The format of the address returned depends on the address family ---
see above.) see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{getsockopt}{level, optname\optional{, buflen}} \begin{methoddesc}[socket]{getsockopt}{level, optname\optional{, buflen}}
Return the value of the given socket option (see the \UNIX{} man page Return the value of the given socket option (see the \UNIX{} man page
\manpage{getsockopt}{2}). The needed symbolic constants \manpage{getsockopt}{2}). The needed symbolic constants
(\constant{SO_*} etc.) are defined in this module. If \var{buflen} (\constant{SO_*} etc.) are defined in this module. If \var{buflen}
@ -252,15 +251,15 @@ the maximum length of the buffer used to receive the option in, and
this buffer is returned as a string. It is up to the caller to decode this buffer is returned as a string. It is up to the caller to decode
the contents of the buffer (see the optional built-in module the contents of the buffer (see the optional built-in module
\module{struct} for a way to decode C structures encoded as strings). \module{struct} for a way to decode C structures encoded as strings).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{listen}{backlog} \begin{methoddesc}[socket]{listen}{backlog}
Listen for connections made to the socket. The \var{backlog} argument Listen for connections made to the socket. The \var{backlog} argument
specifies the maximum number of queued connections and should be at specifies the maximum number of queued connections and should be at
least 1; the maximum value is system-dependent (usually 5). least 1; the maximum value is system-dependent (usually 5).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{makefile}{\optional{mode\optional{, bufsize}}} \begin{methoddesc}[socket]{makefile}{\optional{mode\optional{, bufsize}}}
Return a \dfn{file object} associated with the socket. (File objects Return a \dfn{file object} associated with the socket. (File objects
were described earlier in \ref{bltin-file-objects}, ``File Objects.'') were described earlier in \ref{bltin-file-objects}, ``File Objects.'')
The file object references a \cfunction{dup()}ped version of the The file object references a \cfunction{dup()}ped version of the
@ -268,49 +267,49 @@ socket file descriptor, so the file object and socket object may be
closed or garbage-collected independently. The optional \var{mode} closed or garbage-collected independently. The optional \var{mode}
and \var{bufsize} arguments are interpreted the same way as by the and \var{bufsize} arguments are interpreted the same way as by the
built-in \function{open()} function. built-in \function{open()} function.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{recv}{bufsize\optional{, flags}} \begin{methoddesc}[socket]{recv}{bufsize\optional{, flags}}
Receive data from the socket. The return value is a string representing Receive data from the socket. The return value is a string representing
the data received. The maximum amount of data to be received the data received. The maximum amount of data to be received
at once is specified by \var{bufsize}. See the \UNIX{} manual page at once is specified by \var{bufsize}. See the \UNIX{} manual page
\manpage{recv}{2} for the meaning of the optional argument \manpage{recv}{2} for the meaning of the optional argument
\var{flags}; it defaults to zero. \var{flags}; it defaults to zero.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{recvfrom}{bufsize\optional{, flags}} \begin{methoddesc}[socket]{recvfrom}{bufsize\optional{, flags}}
Receive data from the socket. The return value is a pair Receive data from the socket. The return value is a pair
\code{(\var{string}, \var{address})} where \var{string} is a string \code{(\var{string}, \var{address})} where \var{string} is a string
representing the data received and \var{address} is the address of the representing the data received and \var{address} is the address of the
socket sending the data. The optional \var{flags} argument has the socket sending the data. The optional \var{flags} argument has the
same meaning as for \method{recv()} above. same meaning as for \method{recv()} above.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{send}{string\optional{, flags}} \begin{methoddesc}[socket]{send}{string\optional{, flags}}
Send data to the socket. The socket must be connected to a remote 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 socket. The optional \var{flags} argument has the same meaning as for
\method{recv()} above. Returns the number of bytes sent. \method{recv()} above. Returns the number of bytes sent.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{sendto}{string\optional{, flags}, address} \begin{methoddesc}[socket]{sendto}{string\optional{, flags}, address}
Send data to the socket. The socket should not be connected to a Send data to the socket. The socket should not be connected to a
remote socket, since the destination socket is specified by remote socket, since the destination socket is specified by
\var{address}. The optional \var{flags} argument has the same \var{address}. The optional \var{flags} argument has the same
meaning as for \method{recv()} above. Return the number of bytes sent. meaning as for \method{recv()} above. Return the number of bytes sent.
(The format of \var{address} depends on the address family --- see above.) (The format of \var{address} depends on the address family --- see above.)
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{setblocking}{flag} \begin{methoddesc}[socket]{setblocking}{flag}
Set blocking or non-blocking mode of the socket: if \var{flag} is 0, Set blocking or non-blocking mode of the socket: if \var{flag} is 0,
the socket is set to non-blocking, else to blocking mode. Initially the socket is set to non-blocking, else to blocking mode. Initially
all sockets are in blocking mode. In non-blocking mode, if a all sockets are in blocking mode. In non-blocking mode, if a
\method{recv()} call doesn't find any data, or if a \code{send} call can't \method{recv()} call doesn't find any data, or if a \code{send} call can't
immediately dispose of the data, a \exception{error} exception is immediately dispose of the data, a \exception{error} exception is
raised; in blocking mode, the calls block until they can proceed. raised; in blocking mode, the calls block until they can proceed.
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{setsockopt}{level, optname, value} \begin{methoddesc}[socket]{setsockopt}{level, optname, value}
Set the value of the given socket option (see the \UNIX{} man page Set the value of the given socket option (see the \UNIX{} man page
\manpage{setsockopt}{2}). The needed symbolic constants are defined in \manpage{setsockopt}{2}). The needed symbolic constants are defined in
the \module{socket} module (\code{SO_*} etc.). The value can be an the \module{socket} module (\code{SO_*} etc.). The value can be an
@ -319,14 +318,14 @@ up to the caller to ensure that the string contains the proper bits
(see the optional built-in module (see the optional built-in module
\module{struct}\refbimodindex{struct} for a way to encode C structures \module{struct}\refbimodindex{struct} for a way to encode C structures
as strings). as strings).
\end{funcdesc} \end{methoddesc}
\begin{funcdesc}{shutdown}{how} \begin{methoddesc}[socket]{shutdown}{how}
Shut down one or both halves of the connection. If \var{how} is Shut down one or both halves of the connection. If \var{how} is
\code{0}, further receives are disallowed. If \var{how} is \code{1}, \code{0}, further receives are disallowed. If \var{how} is \code{1},
further sends are disallowed. If \var{how} is \code{2}, further sends further sends are disallowed. If \var{how} is \code{2}, further sends
and receives are disallowed. and receives are disallowed.
\end{funcdesc} \end{methoddesc}
Note that there are no methods \method{read()} or \method{write()}; Note that there are no methods \method{read()} or \method{write()};
use \method{recv()} and \method{send()} without \var{flags} argument use \method{recv()} and \method{send()} without \var{flags} argument