Mercurial > cpython-lru_cache-weakref
annotate Modules/socketmodule.h @ 58664:993f703a61ba
Merged revisions 77484,77487,77561,77570,77593,77603,77608,77667,77702-77703,77739,77858,77887,77889 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77484 | skip.montanaro | 2010-01-13 19:12:34 -0600 (Wed, 13 Jan 2010) | 4 lines
Update PyEval_EvalFrame to PyEval_EvalFrameEx. This looks to have been done
partially before. Also add a comment describing how this might have to work
with different versions of the interpreter.
........
r77487 | ezio.melotti | 2010-01-14 05:34:10 -0600 (Thu, 14 Jan 2010) | 1 line
Fixed typo
........
r77561 | georg.brandl | 2010-01-17 02:42:30 -0600 (Sun, 17 Jan 2010) | 1 line
#7699: improve datetime docs: straightforward linking to strftime/strptime section, mark classmethods as such.
........
r77570 | georg.brandl | 2010-01-17 06:14:42 -0600 (Sun, 17 Jan 2010) | 1 line
Add note about usage of STRINGLIB_EMPTY.
........
r77593 | georg.brandl | 2010-01-17 17:33:53 -0600 (Sun, 17 Jan 2010) | 1 line
Fix internal reference.
........
r77603 | benjamin.peterson | 2010-01-18 17:07:56 -0600 (Mon, 18 Jan 2010) | 8 lines
data descriptors do not override the class dictionary if __get__ is not defined
Adjust documentation and add a test to verify this behavior.
See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for
discussion.
........
r77608 | gregory.p.smith | 2010-01-19 02:19:03 -0600 (Tue, 19 Jan 2010) | 6 lines
Do not compile stubs for the sha2 series hashes in the openssl hashlib
module when the openssl version is too old to support them. That
leads both compiled code bloat and to unittests attempting to test
implementations that don't exist for comparison purposes on such
platforms.
........
r77667 | mark.dickinson | 2010-01-21 12:32:27 -0600 (Thu, 21 Jan 2010) | 1 line
Add two more test_strtod test values.
........
r77702 | georg.brandl | 2010-01-23 02:43:31 -0600 (Sat, 23 Jan 2010) | 1 line
#7762: fix refcount annotation of PyUnicode_Tailmatch().
........
r77703 | georg.brandl | 2010-01-23 02:47:54 -0600 (Sat, 23 Jan 2010) | 1 line
#7725: fix referencing issue.
........
r77739 | benjamin.peterson | 2010-01-24 21:52:52 -0600 (Sun, 24 Jan 2010) | 1 line
mention from_float() in error message
........
r77858 | georg.brandl | 2010-01-30 11:57:48 -0600 (Sat, 30 Jan 2010) | 1 line
#7802: fix invalid example (heh).
........
r77887 | georg.brandl | 2010-01-31 12:51:49 -0600 (Sun, 31 Jan 2010) | 5 lines
Fix-up ftplib documentation:
move exception descriptions to toplevel, not inside a class
remove attribution in "versionadded"
spell and grammar check docstring of FTP_TLS
........
r77889 | michael.foord | 2010-01-31 13:59:26 -0600 (Sun, 31 Jan 2010) | 1 line
Minor modification to unittest documentation.
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 03 Feb 2010 02:35:45 +0000 |
| parents | 5c8b2238a2f5 |
| children | cab14be0ada1 |
| rev | line source |
|---|---|
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
1 /* Socket module header file */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
2 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
3 /* Includes needed for the sockaddr_* symbols below */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
4 #ifndef MS_WINDOWS |
|
28949
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
5 #ifdef __VMS |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
6 # include <socket.h> |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
7 # else |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
8 # include <sys/socket.h> |
|
ac487a7f7f2c
Patch #708495: Port more stuff to OpenVMS.
Martin v. Löwis <martin@v.loewis.de>
parents:
23815
diff
changeset
|
9 # endif |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
10 # include <netinet/in.h> |
|
44082
4cb95fc4129e
Marc-Andre Lemburg has found the culprit of the problem in r57142.
Christian Heimes <christian@cheimes.de>
parents:
42645
diff
changeset
|
11 # if !(defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
12 # include <netinet/tcp.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
13 # endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
14 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
15 #else /* MS_WINDOWS */ |
|
22096
9e5ff6747437
Patch #520062: Support IPv6 with VC.NET.
Martin v. Löwis <martin@v.loewis.de>
parents:
22041
diff
changeset
|
16 # include <winsock2.h> |
|
9e5ff6747437
Patch #520062: Support IPv6 with VC.NET.
Martin v. Löwis <martin@v.loewis.de>
parents:
22041
diff
changeset
|
17 # include <ws2tcpip.h> |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
18 /* VC6 is shipped with old platform headers, and does not have MSTcpIP.h |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
19 * Separate SDKs have all the functions we want, but older ones don't have |
|
47718
96bff7e137fb
Merged revisions 64267-64272 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
47667
diff
changeset
|
20 * any version information. |
|
96bff7e137fb
Merged revisions 64267-64272 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
47667
diff
changeset
|
21 * I use SIO_GET_MULTICAST_FILTER to detect a decent SDK. |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
22 */ |
|
47718
96bff7e137fb
Merged revisions 64267-64272 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
47667
diff
changeset
|
23 # ifdef SIO_GET_MULTICAST_FILTER |
|
47667
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
24 # include <MSTcpIP.h> /* for SIO_RCVALL */ |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
25 # define HAVE_ADDRINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
26 # define HAVE_SOCKADDR_STORAGE |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
27 # define HAVE_GETADDRINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
28 # define HAVE_GETNAMEINFO |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
29 # define ENABLE_IPV6 |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
30 # else |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
31 typedef int socklen_t; |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
32 # endif /* IPPROTO_IPV6 */ |
|
b1f4ea4eb555
Merged revisions 64214 via svnmerge from
Amaury Forgeot d'Arc <amauryfa@gmail.com>
parents:
44568
diff
changeset
|
33 #endif /* MS_WINDOWS */ |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
34 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
35 #ifdef HAVE_SYS_UN_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
36 # include <sys/un.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
37 #else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
38 # undef AF_UNIX |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
39 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
40 |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
41 #ifdef HAVE_LINUX_NETLINK_H |
|
36298
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
42 # ifdef HAVE_ASM_TYPES_H |
|
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
43 # include <asm/types.h> |
|
9eeaa33f9640
Get socketmodule to build after adding netlink support.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36286
diff
changeset
|
44 # endif |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
45 # include <linux/netlink.h> |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
46 #else |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
47 # undef AF_NETLINK |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
48 #endif |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
49 |
|
31441
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
50 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
51 #include <bluetooth/bluetooth.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
52 #include <bluetooth/rfcomm.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
53 #include <bluetooth/l2cap.h> |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
54 #include <bluetooth/sco.h> |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
55 #include <bluetooth/hci.h> |
|
31441
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
56 #endif |
|
493707692671
Patch #874083: Bluetooth support for socket module.
Martin v. Löwis <martin@v.loewis.de>
parents:
28949
diff
changeset
|
57 |
|
31444
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
58 #ifdef HAVE_BLUETOOTH_H |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
59 #include <bluetooth.h> |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
60 #endif |
|
a282801b06b6
Add FreeBSD support for bluetooth sockets. (SF Patch #888148)
Hye-Shik Chang <hyeshik@gmail.com>
parents:
31441
diff
changeset
|
61 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
62 #ifdef HAVE_NETPACKET_PACKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
63 # include <sys/ioctl.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
64 # include <net/if.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
65 # include <netpacket/packet.h> |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
66 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
67 |
|
44568
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
68 #ifdef HAVE_LINUX_TIPC_H |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
69 # include <linux/tipc.h> |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
70 #endif |
|
305d7d2ce047
Copied doc for reload() from trunk's function.rst to imp.rst
Christian Heimes <christian@cheimes.de>
parents:
44535
diff
changeset
|
71 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
72 #ifndef Py__SOCKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
73 #define Py__SOCKET_H |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
74 #ifdef __cplusplus |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
75 extern "C" { |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
76 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
77 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
78 /* Python module and C API name */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
79 #define PySocket_MODULE_NAME "_socket" |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
80 #define PySocket_CAPI_NAME "CAPI" |
|
53816
911df82bc25d
add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents:
47718
diff
changeset
|
81 #define PySocket_CAPSULE_NAME PySocket_MODULE_NAME "." PySocket_CAPI_NAME |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
82 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
83 /* Abstract the socket file descriptor type */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
84 #ifdef MS_WINDOWS |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
85 typedef SOCKET SOCKET_T; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
86 # ifdef MS_WIN64 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
87 # define SIZEOF_SOCKET_T 8 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
88 # else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
89 # define SIZEOF_SOCKET_T 4 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
90 # endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
91 #else |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
92 typedef int SOCKET_T; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
93 # define SIZEOF_SOCKET_T SIZEOF_INT |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
94 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
95 |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
96 /* Socket address */ |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
97 typedef union sock_addr { |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
98 struct sockaddr_in in; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
99 #ifdef AF_UNIX |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
100 struct sockaddr_un un; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
101 #endif |
|
36286
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
102 #ifdef AF_NETLINK |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
103 struct sockaddr_nl nl; |
|
ae4480935016
Patch #1103116: AF_NETLINK sockets basic support.
Martin v. Löwis <martin@v.loewis.de>
parents:
35551
diff
changeset
|
104 #endif |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
105 #ifdef ENABLE_IPV6 |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
106 struct sockaddr_in6 in6; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
107 struct sockaddr_storage storage; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
108 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
109 #ifdef HAVE_BLUETOOTH_BLUETOOTH_H |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
110 struct sockaddr_l2 bt_l2; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
111 struct sockaddr_rc bt_rc; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
112 struct sockaddr_sco bt_sco; |
|
40893
32c4897b5d46
Merged revisions 53623-53858 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
40450
diff
changeset
|
113 struct sockaddr_hci bt_hci; |
|
35551
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
114 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
115 #ifdef HAVE_NETPACKET_PACKET_H |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
116 struct sockaddr_ll ll; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
117 #endif |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
118 } sock_addr_t; |
|
57f630a9de26
- Changes donated by Elemental Security to make it work on AIX 5.3
Guido van Rossum <guido@python.org>
parents:
31790
diff
changeset
|
119 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
120 /* The object holding a socket. It holds some extra information, |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
121 like the address family, which is used to decode socket address |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
122 arguments properly. */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
123 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
124 typedef struct { |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
125 PyObject_HEAD |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
126 SOCKET_T sock_fd; /* Socket file descriptor */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
127 int sock_family; /* Address family, e.g., AF_INET */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
128 int sock_type; /* Socket type, e.g., SOCK_STREAM */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
129 int sock_proto; /* Protocol type, usually 0 */ |
|
21969
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
130 PyObject *(*errorhandler)(void); /* Error handler; checks |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
131 errno, returns NULL and |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
132 sets a Python exception */ |
|
23815
203d1412a7e8
Major overhaul of timeout sockets:
Guido van Rossum <guido@python.org>
parents:
23724
diff
changeset
|
133 double sock_timeout; /* Operation timeout in seconds; |
|
203d1412a7e8
Major overhaul of timeout sockets:
Guido van Rossum <guido@python.org>
parents:
23724
diff
changeset
|
134 0.0 means non-blocking */ |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
135 } PySocketSockObject; |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
136 |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
137 /* --- C API ----------------------------------------------------*/ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
138 |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
139 /* Short explanation of what this C API export mechanism does |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
140 and how it works: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
141 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
142 The _ssl module needs access to the type object defined in |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
143 the _socket module. Since cross-DLL linking introduces a lot of |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
144 problems on many platforms, the "trick" is to wrap the |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
145 C API of a module in a struct which then gets exported to |
|
53816
911df82bc25d
add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents:
47718
diff
changeset
|
146 other modules via a PyCapsule. |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
147 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
148 The code in socketmodule.c defines this struct (which currently |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
149 only contains the type object reference, but could very |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
150 well also include other C APIs needed by other modules) |
|
53816
911df82bc25d
add a replacement API for PyCObject, PyCapsule #5630
Benjamin Peterson <benjamin@python.org>
parents:
47718
diff
changeset
|
151 and exports it as PyCapsule via the module dictionary |
|
22041
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
152 under the name "CAPI". |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
153 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
154 Other modules can now include the socketmodule.h file |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
155 which defines the needed C APIs to import and set up |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
156 a static copy of this struct in the importing module. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
157 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
158 After initialization, the importing module can then |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
159 access the C APIs from the _socket module by simply |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
160 referring to the static struct, e.g. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
161 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
162 Load _socket module and its C API; this sets up the global |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
163 PySocketModule: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
164 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
165 if (PySocketModule_ImportModuleAndAPI()) |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
166 return; |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
167 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
168 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
169 Now use the C API as if it were defined in the using |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
170 module: |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
171 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
172 if (!PyArg_ParseTuple(args, "O!|zz:ssl", |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
173 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
174 PySocketModule.Sock_Type, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
175 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
176 (PyObject*)&Sock, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
177 &key_file, &cert_file)) |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
178 return NULL; |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
179 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
180 Support could easily be extended to export more C APIs/symbols |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
181 this way. Currently, only the type object is exported, |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
182 other candidates would be socket constructors and socket |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
183 access functions. |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
184 |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
185 */ |
|
e0a288db022d
Add documentation about how the inter-module linking works.
Marc-André Lemburg <mal@egenix.com>
parents:
21970
diff
changeset
|
186 |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
187 /* C API for usage by other Python modules */ |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
188 typedef struct { |
|
21969
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
189 PyTypeObject *Sock_Type; |
|
31790
29da8bdfeb4e
Make socket.sslerror a subclass of socket.error .
Brett Cannon <bcannon@gmail.com>
parents:
31444
diff
changeset
|
190 PyObject *error; |
|
21969
72c95448ee4b
For readability, switch to tab indents; was using a mix of tab indents,
Tim Peters <tim.peters@gmail.com>
parents:
21959
diff
changeset
|
191 } PySocketModule_APIObject; |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
192 |
|
53824
b666e72f602f
turn this into a macro
Benjamin Peterson <benjamin@python.org>
parents:
53816
diff
changeset
|
193 #define PySocketModule_ImportModuleAndAPI() PyCapsule_Import(PySocket_CAPSULE_NAME, 1) |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
194 |
|
55573
5c8b2238a2f5
Merged revisions 74356-74357 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents:
53824
diff
changeset
|
195 #ifdef __cplusplus |
|
21959
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
196 } |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
197 #endif |
|
3957d155f8c5
Break SSL support out of _socket module and place it into a new
Marc-André Lemburg <mal@egenix.com>
parents:
diff
changeset
|
198 #endif /* !Py__SOCKET_H */ |
