File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -381,6 +381,8 @@ Constants
381381
382382 .. versionchanged :: 3.10
383383 ``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.
384386
385387.. data :: AF_CAN
386388 PF_CAN
Original file line number Diff line number Diff line change @@ -6446,6 +6446,12 @@ def test_length_restriction(self):
64466446 sock .bind (("type" , "n" * 64 ))
64476447
64486448
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+
64496455@unittest .skipUnless (sys .platform .startswith ("win" ), "requires Windows" )
64506456class TestMSWindowsTCPFlags (unittest .TestCase ):
64516457 knownTCPFlags = {
@@ -6704,6 +6710,7 @@ def test_main():
67046710 SendfileUsingSendfileTest ,
67056711 ])
67066712 tests .append (TestMSWindowsTCPFlags )
6713+ tests .append (TestMacOSTCPFlags )
67076714
67086715 thread_info = threading_helper .threading_setup ()
67096716 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)
81588158#endif
81598159#ifdef TCP_KEEPIDLE
81608160 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 );
81618165#endif
81628166#ifdef TCP_KEEPINTVL
81638167 PyModule_AddIntMacro (m , TCP_KEEPINTVL );
You can’t perform that action at this time.
0 commit comments