mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
bpo-34932: Add socket.TCP_KEEPALIVE for macOS (GH-25079)
(cherry picked from commit d59d7374a3
)
Co-authored-by: Shane Harvey <shnhrv@gmail.com>
This commit is contained in:
parent
02e4c0cad3
commit
ff7af2203c
4 changed files with 14 additions and 0 deletions
|
@ -381,6 +381,8 @@ Constants
|
|||
|
||||
.. versionchanged:: 3.10
|
||||
``IP_RECVTOS`` was added.
|
||||
Added ``TCP_KEEPALIVE``. On MacOS this constant can be used in the same
|
||||
way that ``TCP_KEEPIDLE`` is used on Linux.
|
||||
|
||||
.. data:: AF_CAN
|
||||
PF_CAN
|
||||
|
|
|
@ -6411,6 +6411,12 @@ class LinuxKernelCryptoAPI(unittest.TestCase):
|
|||
sock.bind(("type", "n" * 64))
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test')
|
||||
class TestMacOSTCPFlags(unittest.TestCase):
|
||||
def test_tcp_keepalive(self):
|
||||
self.assertTrue(socket.TCP_KEEPALIVE)
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
|
||||
class TestMSWindowsTCPFlags(unittest.TestCase):
|
||||
knownTCPFlags = {
|
||||
|
@ -6669,6 +6675,7 @@ def test_main():
|
|||
SendfileUsingSendfileTest,
|
||||
])
|
||||
tests.append(TestMSWindowsTCPFlags)
|
||||
tests.append(TestMacOSTCPFlags)
|
||||
|
||||
thread_info = threading_helper.threading_setup()
|
||||
support.run_unittest(*tests)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Add socket.TCP_KEEPALIVE support for macOS. Patch by Shane Harvey.
|
|
@ -8158,6 +8158,10 @@ PyInit__socket(void)
|
|||
#endif
|
||||
#ifdef TCP_KEEPIDLE
|
||||
PyModule_AddIntMacro(m, TCP_KEEPIDLE);
|
||||
#endif
|
||||
/* TCP_KEEPALIVE is OSX's TCP_KEEPIDLE equivalent */
|
||||
#if defined(__APPLE__) && defined(TCP_KEEPALIVE)
|
||||
PyModule_AddIntMacro(m, TCP_KEEPALIVE);
|
||||
#endif
|
||||
#ifdef TCP_KEEPINTVL
|
||||
PyModule_AddIntMacro(m, TCP_KEEPINTVL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue