summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-132987: Support __index__() in the socket module (GH-133093)Serhiy Storchaka2025-04-291-142/+119
| | | | | | | | ntohl(), htonl(), if_indextoname(), getaddrinfo() now use __index__() if available. Also fix the Argument Clinic names for module-level functions (although this does not affect the user).
* gh-132991: Add socket.IP_FREEBIND constant (GH-132998)Alyssa Ross2025-04-261-0/+3
|
* gh-132734: Fix build on FreeBSD and old Linux (GH-132829)Serhiy Storchaka2025-04-231-1/+11
|
* gh-132734: Add new constants for Bluetooth sockets (GH-132735)Serhiy Storchaka2025-04-221-4/+133
|
* gh-129719: Restore missing `socket.CAN_RAW_ERR_FILTER` on Linux (#129721)Jeroen Bogers2025-04-181-1/+1
| | | | Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
* gh-132099: Accept an integer as the address for BTPROTO_HCI on Linux (GH-132525)Serhiy Storchaka2025-04-161-1/+6
| | | | | | Previously only an integer packed in a tuple was accepted, while getsockname() could return a raw integer. Now the result of getsockname() is always acceptable as an address.
* gh-70145: Add support for channels in Bluetooth HCI protocol (GH-132481)Serhiy Storchaka2025-04-141-3/+19
|
* gh-132099: Harmonize Bluetooth address handling (GH-132486)Serhiy Storchaka2025-04-141-22/+21
| | | | | | | | | | Now all protocols always accept the Bluetooth address as string and getsockname() always returns the Bluetooth address as string. * BTPROTO_SCO now accepts not only bytes, but str. * BTPROTO_SCO now checks address for embedded null. * On *BSD, BTPROTO_HCI now accepts str instead of bytes. * On FreeBSD, getsockname() for BTPROTO_HCI now returns str instead of bytes. * On NetBSD and DragonFly BDS, BTPROTO_HCI now checks address for embedded null.
* gh-132429: Fix support of Bluetooth sockets on NetBSD and DragonFly BSD ↵Serhiy Storchaka2025-04-121-68/+91
| | | | | | | (GH-132431) * Also add support for cid and bdaddr_type in the BTPROTO_L2CAP address on FreeBSD. * Return cid in getsockname() for BTPROTO_L2CAP if it is not zero. * Fix a compiler warning on FreeBSD.
* gh-85302: Add support for BTPROTO_SCO on FreeBSD (GH-131981)Serhiy Storchaka2025-04-111-8/+10
| | | | BTPROTO_SCO has been supported on FreeBSD since 2008.
* gh-132075: Fix possible use of sockaddr structures with uninitialized ↵Serhiy Storchaka2025-04-041-0/+13
| | | | | members (GH-132076) Now all structure members are initialized with zeroes by default.
* gh-111178: Fix getsockaddrarg() undefined behavior (#131668)Victor Stinner2025-04-011-14/+56
| | | | | | | | Don't pass direct references to sockaddr members since their type may not match PyArg_ParseTuple() types. Instead, use temporary 'int' and 'unsigned char' variables, and update sockaddr members afterwards. On FreeBSD, treat BTPROTO_HCI node name as a bytes string, not as an integer.
* gh-111178: Fix function signatures for test_socket (#131667)Victor Stinner2025-03-241-12/+16
| | | | Add unicode_fsdecode() wrapper for PyUnicode_DecodeFSDefault() to use the correct API for Py_BuildValue() converter API.
* gh-111178: Fix function signatures for test_os (#131227)Victor Stinner2025-03-141-1/+2
|
* gh-130099: Fix CAN socket fallthrough annotation for NetBSD compatibility ↵Furkan Onder2025-03-131-0/+2
| | | | (#131026)
* Remove vestigial code in socketmodule.c for Mac OS X 10.1 (#131090)Max Bachmann2025-03-131-15/+0
|
* gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket ↵Fredrik Ahlberg2025-02-271-5/+22
| | | | | | | | | | address tuple (#129293) Add two optional, traling elements in the AF_BLUETOOTH socket address tuple: - l2_cid, to allow e.g raw LE ATT connections - l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices, the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.
* gh-129354: Use PyErr_FormatUnraisable() function (#129656)Victor Stinner2025-02-041-1/+2
| | | Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
* gh-128452: fix warning in socketmodule.c (#129478)Kumar Aditya2025-01-311-0/+2
|
* gh-111178: fix UBSan failures in `Modules/socketmodule.c` (GH-128249)Bénédikt Tran2025-01-271-98/+154
|
* gh-128360: Add `_Py_AssertHoldsTstate` as assertion for holding a thread ↵Peter Bierma2025-01-201-4/+5
| | | | | state (#128361) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
* gh-128277: remove unnecessary critical section from `socket.close` (#128305)Kumar Aditya2025-01-011-2/+1
| | | Remove unnecessary critical section from `socket.close` as it now uses relaxed atomics for `sock_fd`.
* gh-128277: make globals variables thread safe in socket module (#128286)Kumar Aditya2024-12-311-33/+23
|
* gh-128277: use relaxed atomics for `sock_fd` (#128304)Kumar Aditya2024-12-311-65/+102
|
* gh-124761: add `socket.SO_REUSEPORT_LB` (#124961)Thomas Grainger2024-12-261-0/+3
|
* gh-127072: Remove outdated `socket.NETLINK_*` constants. (GH-127256)RUANG (James Roy)2024-11-271-18/+2
| | | | | Remove seriously outdated netlink constants. Co-authored-by: Gregory P. Smith <greg@krypto.org>
* gh-126876: Fix socket internal_select() for large timeout (#126968)Victor Stinner2024-11-191-1/+4
| | | | | | If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
* gh-118986: expose `socket.IPV6_RECVERR` (#118987)chrysn2024-10-171-0/+3
|
* gh-124944: Add socket.SO_ORIGINAL_DST (#124945)Steven Jin2024-10-141-0/+3
|
* gh-115754: Use Py_GetConstant(Py_CONSTANT_EMPTY_STR) (#125194)Victor Stinner2024-10-091-1/+1
| | | | | Replace PyUnicode_New(0, 0), PyUnicode_FromString("") and PyUnicode_FromStringAndSize("", 0) with Py_GetConstant(Py_CONSTANT_EMPTY_STR).
* gh-84808: socket.connect_ex: Handle negative errno (GH-122304)Jérôme Duval2024-09-091-2/+17
| | | | | POSIX allows errno to be negative. Even though all currently supported platforms have non-negative errno, relying on a quirk like that would make Python less portable.
* gh-123476: Add support for TCP_QUICKACK socket setting to Windows (#123478)nkinnan2024-09-051-0/+22
| | | | | Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Steve Dower <steve.dower@microsoft.com>
* gh-117657: Use critical section to make _socket.socket.close thread safe ↵AN Long2024-07-011-8/+13
| | | | (GH-120490)
* gh-121040: Use __attribute__((fallthrough)) (#121044)Victor Stinner2024-06-271-4/+7
| | | | | | | | | | | | | Fix warnings when using -Wimplicit-fallthrough compiler flag. Annotate explicitly "fall through" switch cases with a new _Py_FALLTHROUGH macro which uses __attribute__((fallthrough)) if available. Replace "fall through" comments with _Py_FALLTHROUGH. Add _Py__has_attribute() macro. No longer define __has_attribute() macro if it's not defined. Move also _Py__has_builtin() at the top of pyport.h. Co-Authored-By: Nikita Sobolev <mail@sobolevn.me>
* gh-120056: Add `IP_RECVERR`, `IP_RECVORIGDSTADDR`, `IP_RECVTTL` to `socket` ↵Nikita Sobolev2024-06-121-0/+9
| | | | | | | | | | | module (#120058) * gh-120056: Add `IP_RECVERR` and `IP_RECVTTL` to `socket` module * Fix news * Address review * Update NEWS
* gh-119461: Fix ThreadedVSOCKSocketStreamTest (#119465)Victor Stinner2024-05-231-0/+1
| | | | | | | | | | Add socket.VMADDR_CID_LOCAL constant. Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the host address or the "any" address, use the local communication address (loopback): VMADDR_CID_LOCAL. On Linux 6.9, apparently, the /dev/vsock device is now available but get_cid() returns VMADDR_CID_ANY (-1).
* gh-116322: Add Py_mod_gil module slot (#116882)Brett Simmers2024-05-031-0/+1
| | | | | | | | | | | | | | This PR adds the ability to enable the GIL if it was disabled at interpreter startup, and modifies the multi-phase module initialization path to enable the GIL when loading a module, unless that module's spec includes a slot indicating it can run safely without the GIL. PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148. A warning will be issued up to once per interpreter for the first GIL-using module that is loaded. If `-v` is given, a shorter message will be printed to stderr every time a GIL-using module is loaded (including the first one that issues a warning).
* gh-116616: Use relaxed atomic ops to access socket module defaulttimeout ↵Erlend E. Aasland2024-03-121-5/+6
| | | | | (#116623) Co-authored-by: Sam Gross <colesbury@gmail.com>
* gh-110850: Use public PyTime functions (#115746)Victor Stinner2024-02-201-2/+2
| | | | | Replace private _PyTime functions with public PyTime functions. random_seed_time_pid() now reports errors to its caller.
* gh-104061: Add socket.SO_BINDTOIFINDEX constant (GH-104062)Victor Westerhuis2024-02-201-0/+3
| | | | | Add socket.SO_BINDTOIFINDEX constant This socket option avoids a race condition between SO_BINDTODEVICE and network interface renaming.
* gh-110850: Cleanup pycore_time.h includes (#115724)Victor Stinner2024-02-201-0/+1
| | | | | <pycore_time.h> include is no longer needed to get the PyTime_t type in internal header files. This type is now provided by <Python.h> include. Add <pycore_time.h> includes to C files instead.
* gh-110850: Replace _PyTime_t with PyTime_t (#115719)Victor Stinner2024-02-201-12/+12
| | | | | Run command: sed -i -e 's!\<_PyTime_t\>!PyTime_t!g' $(find -name "*.c" -o -name "*.h")
* bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503)Zackery Spytz2023-12-011-5/+11
| | | | | * Fix a crash when pass UINT_MAX. * Fix an integer overflow on 64-bit non-Windows platforms.
* gh-111995: Add getnameinfo extension flag (#111994)adder322023-11-151-0/+3
| | | Add getnameinfo extension NI_IDN flag.
* gh-111262: Add PyDict_Pop() function (#112028)Victor Stinner2023-11-141-8/+2
| | | | | | | _PyDict_Pop_KnownHash(): remove the default value and the return type becomes an int. Co-authored-by: Stefan Behnel <stefan_ml@behnel.de> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
* gh-111662: Update socket module to use AC for optimizing performance (gh-111661)Bogdan Romanyuk2023-11-081-68/+59
|
* gh-106320: Re-add some PyLong/PyDict C-API functions (GH-#111162)scoder2023-10-251-1/+0
| | | | | | | | * gh-106320: Re-add _PyLong_FromByteArray(), _PyLong_AsByteArray() and _PyLong_GCD() to the public header files since they are used by third-party packages and there is no efficient replacement. See https://github.com/python/cpython/issues/111140 See https://github.com/python/cpython/issues/111139 * gh-111262: Re-add _PyDict_Pop() to have a C-API until a new public one is designed.
* gh-111253: Fix error checking in _socket module init (#111254)Nikita Sobolev2023-10-251-2/+2
|
* gh-110093: Partially revert previous change in socketmodule.c (GH-111120)Serhiy Storchaka2023-10-201-1/+3
|
* gh-110093: Replace trivial Py_BuildValue() with direct C API call (GH-110094)Serhiy Storchaka2023-10-201-3/+1
|