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 @@ -6411,6 +6411,12 @@ def test_length_restriction(self):
6411
6411
sock .bind (("type" , "n" * 64 ))
6412
6412
6413
6413
6414
+ @unittest .skipUnless (sys .platform == 'darwin' , 'macOS specific test' )
6415
+ class TestMacOSTCPFlags (unittest .TestCase ):
6416
+ def test_tcp_keepalive (self ):
6417
+ self .assertTrue (socket .TCP_KEEPALIVE )
6418
+
6419
+
6414
6420
@unittest .skipUnless (sys .platform .startswith ("win" ), "requires Windows" )
6415
6421
class TestMSWindowsTCPFlags (unittest .TestCase ):
6416
6422
knownTCPFlags = {
@@ -6669,6 +6675,7 @@ def test_main():
6669
6675
SendfileUsingSendfileTest ,
6670
6676
])
6671
6677
tests .append (TestMSWindowsTCPFlags )
6678
+ tests .append (TestMacOSTCPFlags )
6672
6679
6673
6680
thread_info = threading_helper .threading_setup ()
6674
6681
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