File tree Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Expand file tree Collapse file tree 4 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -381,6 +381,8 @@ Constants
381
381
382
382
.. versionchanged :: 3.10
383
383
``IP_RECVTOS `` was added.
384
+ Added ``TCP_KEEPALIVE ``. On MacOS this constant can be used in the same
385
+ way that ``TCP_KEEPIDLE `` is used on Linux.
384
386
385
387
.. data :: AF_CAN
386
388
PF_CAN
Original file line number Diff line number Diff line change @@ -6446,6 +6446,12 @@ def test_length_restriction(self):
6446
6446
sock .bind (("type" , "n" * 64 ))
6447
6447
6448
6448
6449
+ @unittest .skipUnless (sys .platform == 'darwin' , 'macOS specific test' )
6450
+ class TestMacOSTCPFlags (unittest .TestCase ):
6451
+ def test_tcp_keepalive (self ):
6452
+ self .assertTrue (socket .TCP_KEEPALIVE )
6453
+
6454
+
6449
6455
@unittest .skipUnless (sys .platform .startswith ("win" ), "requires Windows" )
6450
6456
class TestMSWindowsTCPFlags (unittest .TestCase ):
6451
6457
knownTCPFlags = {
@@ -6704,6 +6710,7 @@ def test_main():
6704
6710
SendfileUsingSendfileTest ,
6705
6711
])
6706
6712
tests .append (TestMSWindowsTCPFlags )
6713
+ tests .append (TestMacOSTCPFlags )
6707
6714
6708
6715
thread_info = threading_helper .threading_setup ()
6709
6716
support .run_unittest (* tests )
Original file line number Diff line number Diff line change
1
+ Add socket.TCP_KEEPALIVE support for macOS. Patch by Shane Harvey.
Original file line number Diff line number Diff line change @@ -8158,6 +8158,10 @@ PyInit__socket(void)
8158
8158
#endif
8159
8159
#ifdef TCP_KEEPIDLE
8160
8160
PyModule_AddIntMacro (m , TCP_KEEPIDLE );
8161
+ #endif
8162
+ /* TCP_KEEPALIVE is OSX's TCP_KEEPIDLE equivalent */
8163
+ #if defined(__APPLE__ ) && defined(TCP_KEEPALIVE )
8164
+ PyModule_AddIntMacro (m , TCP_KEEPALIVE );
8161
8165
#endif
8162
8166
#ifdef TCP_KEEPINTVL
8163
8167
PyModule_AddIntMacro (m , TCP_KEEPINTVL );
You can’t perform that action at this time.
0 commit comments