Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d198f385
Commit
d198f385
authored
Apr 25, 2003
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- add availability statements for some of the new APIs
- lots of general cleanup
parent
5ba0054e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
38 deletions
+38
-38
Doc/lib/libsocket.tex
Doc/lib/libsocket.tex
+38
-38
No files found.
Doc/lib/libsocket.tex
View file @
d198f385
...
...
@@ -156,13 +156,14 @@ supported on this platform.
\versionadded
{
2.3
}
\end{datadesc}
\begin{funcdesc}
{
getaddrinfo
}{
host, port
\optional
{
, family, socktype, proto, flags
}}
\begin{funcdesc}
{
getaddrinfo
}{
host, port
\optional
{
, family
\optional
{
,
socktype
\optional
{
, proto
\optional
{
,
flags
}}}}}
Resolves the
\var
{
host
}
/
\var
{
port
}
argument, into a sequence of
5-tuples that contain all the necessary argument for the sockets
manipulation.
\var
{
host
}
is a domain name, a string representation of
IPv4/v6 address or
\code
{
None
}
.
\var
{
port
}
is a string service name (like
\code
{
``http'
'
}
), a numeric
\var
{
port
}
is a string service name (like
\code
{
'http
'
}
), a numeric
port number or
\code
{
None
}
.
The rest of the arguments are optional and must be numeric if
...
...
@@ -171,15 +172,16 @@ string or \code{None}, you can pass \code{NULL} to the C API. The
\function
{
getaddrinfo()
}
function returns a list of 5-tuples with
the following structure:
\code
{
(
\var
{
family
}
,
\var
{
socktype
}
,
\var
{
proto
}
,
\var
{
canonname
}
,
\var
{
sockaddr
}
)
}
.
\code
{
(
\var
{
family
}
,
\var
{
socktype
}
,
\var
{
proto
}
,
\var
{
canonname
}
,
\var
{
sockaddr
}
)
}
\var
{
family
}
,
\var
{
socktype
}
,
\var
{
proto
}
are all integer and are meant to
be passed to the
\function
{
socket()
}
function.
\var
{
canonname
}
is a string representing the canonical name of the
\var
{
host
}
.
It can be a numeric IPv4/v6 address when
\co
de
{
AI
_
CANONNAME
}
is specified
It can be a numeric IPv4/v6 address when
\co
nstant
{
AI
_
CANONNAME
}
is specified
for a numeric
\var
{
host
}
.
\var
{
sockaddr
}
is a tuple describing a socket address, as described above.
See
\code
{
Lib/httplib.py
}
and other library fi
les
See
the source for the
\refmodule
{
httplib
}
and other library modu
les
for a typical usage of the function.
\versionadded
{
2.2
}
\end{funcdesc}
...
...
@@ -206,10 +208,11 @@ is an IPv4 address itself it is returned unchanged. See
\begin{funcdesc}
{
gethostbyname
_
ex
}{
hostname
}
Translate a host name to IPv4 address format, extended interface.
Return a triple
\code
{
(hostname, aliaslist, ipaddrlist)
}
where
\code
{
hostname
}
is the primary host name responding to the given
\var
{
ip
_
address
}
,
\code
{
aliaslist
}
is a (possibly empty) list of
alternative host names for the same address, and
\code
{
ipaddrlist
}
is
Return a triple
\code
{
(
\var
{
hostname
}
,
\var
{
aliaslist
}
,
\var
{
ipaddrlist
}
)
}
where
\var
{
hostname
}
is the primary host name responding to the given
\var
{
ip
_
address
}
,
\var
{
aliaslist
}
is a (possibly empty) list of
alternative host names for the same address, and
\var
{
ipaddrlist
}
is
a list of IPv4 addresses for the same interface on the same
host (often but not always a single address).
\function
{
gethostbyname
_
ex()
}
does not support IPv6 name resolution, and
...
...
@@ -322,11 +325,10 @@ no-op; otherwise, it performs a 2-byte swap operation.
\begin{funcdesc}
{
inet
_
aton
}{
ip
_
string
}
Convert an IPv4 address from dotted-quad string format (for example,
'123.45.67.89') to 32-bit packed binary format, as a string four
characters in length.
Useful when conversing with a program that uses the standard C library
and needs objects of type
\ctype
{
struct in
_
addr
}
, which is the C type
for the 32-bit packed binary this function returns.
characters in length. This is useful when conversing with a program
that uses the standard C library and needs objects of type
\ctype
{
struct in
_
addr
}
, which is the C type for the 32-bit packed
binary this function returns.
If the IPv4 address string passed to this function is invalid,
\exception
{
socket.error
}
will be raised. Note that exactly what is
...
...
@@ -340,16 +342,14 @@ support.
\begin{funcdesc}
{
inet
_
ntoa
}{
packed
_
ip
}
Convert a 32-bit packed IPv4 address (a string four characters in
length) to its standard dotted-quad string representation
(for example, '123.45.67.89').
Useful when conversing with a program that uses the standard C library
and needs objects of type
\ctype
{
struct in
_
addr
}
, which is the C type
for the 32-bit packed binary this function takes as an argument.
length) to its standard dotted-quad string representation (for
example, '123.45.67.89'). This is useful when conversing with a
program that uses the standard C library and needs objects of type
\ctype
{
struct in
_
addr
}
, which is the C type for the 32-bit packed
binary data this function takes as an argument.
If the string passed to this function is not exactly 4 bytes in
length,
\exception
{
socket.error
}
will be raised.
\function
{
inet
_
ntoa()
}
does not support IPv6, and
\function
{
getnameinfo()
}
should be used instead for IPv4/v6 dual stack
support.
...
...
@@ -358,37 +358,37 @@ support.
\begin{funcdesc}
{
inet
_
pton
}{
address
_
family, ip
_
string
}
Convert an IP address from its family-specific string format to a packed,
binary format.
Supported values for address
_
family are currently
\constant
{
AF
_
INET
}
and
\constant
{
AF
_
INET6
}
.
\function
{
inet
_
pton()
}
is useful when a library or network protocol calls for
an object of type
\ctype
{
struct in
_
addr
}
(similar to
\function
{
inet
_
aton()
}
)
or
\ctype
{
struct in6
_
addr
}
.
If the IP address string passed to this function is invalid,
Supported values for
\var
{
address
_
family
}
are currently
\constant
{
AF
_
INET
}
and
\constant
{
AF
_
INET6
}
.
If the IP address string
\var
{
ip
_
string
}
is invalid,
\exception
{
socket.error
}
will be raised. Note that exactly what is valid
depends on both the value of
\var
{
address
_
family
}
and the underlying
implementation of
\cfunction
{
inet
_
pton()
}
.
Availability:
\UNIX
{}
(maybe not all platforms).
\versionadded
{
2.3
}
\end{funcdesc}
\begin{funcdesc}
{
inet
_
ntop
}{
address
_
family, packed
_
ip
}
Convert a packed IP address (a string of some number of characters) to its
standard, family-specific string representation (for example, '7.10.0.5' or
'5aef:2b::8')
Supported values for address
_
family are currently
\constant
{
AF
_
INET
}
and
\constant
{
AF
_
INET6
}
.
Convert a packed IP address (a string of some number of characters) to
its standard, family-specific string representation (for example,
\code
{
'7.10.0.5'
}
or
\code
{
'5aef:2b::8'
}
)
\function
{
inet
_
ntop()
}
is useful when a library or network protocol returns
an object of type
\ctype
{
struct in
_
addr
}
(similar to
\function
{
inet
_
ntoa()
}
)
or
\ctype
{
struct in6
_
addr
}
.
If the string passed to this function is not the correct length for the
specified address family,
\exception
{
ValueError
}
will be raised.
A
\exception
{
socket.error
}
is raised for errors from the call to
Supported values for
\var
{
address
_
family
}
are currently
\constant
{
AF
_
INET
}
and
\constant
{
AF
_
INET6
}
.
If the string
\var
{
packed
_
ip
}
is not the correct length for the
specified address family,
\exception
{
ValueError
}
will be raised. A
\exception
{
socket.error
}
is raised for errors from the call to
\function
{
inet
_
ntop()
}
.
Availability:
\UNIX
{}
(maybe not all platforms).
\versionadded
{
2.3
}
\end{funcdesc}
...
...
@@ -616,7 +616,7 @@ immediately will fail.
\begin{methoddesc}
[socket]
{
setsockopt
}{
level, optname, value
}
Set the value of the given socket option (see the
\UNIX
{}
manual page
\manpage
{
setsockopt
}{
2
}
). The needed symbolic constants are defined in
the
\module
{
socket
}
module (
\co
de
{
SO
_
*
}
etc.). The value can be an
the
\module
{
socket
}
module (
\co
nstant
{
SO
_
*
}
etc.). The value can be an
integer or a string representing a buffer. In the latter case it is
up to the caller to ensure that the string contains the proper bits
(see the optional built-in module
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment