summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authornkinnan <nkinnan@users.noreply.github.com>2024-09-05 20:59:48 (GMT)
committerGitHub <noreply@github.com>2024-09-05 20:59:48 (GMT)
commitb5aa271f86229f126c21805ff2bd3b95526818a4 (patch)
tree3cb1d92269d3b99ec0909e662f07fa7919e6b721 /Lib
parent6e43928831a6f62b40f5e43ad4c12eff0a5f8639 (diff)
downloadcpython-b5aa271f86229f126c21805ff2bd3b95526818a4.zip
cpython-b5aa271f86229f126c21805ff2bd3b95526818a4.tar.gz
cpython-b5aa271f86229f126c21805ff2bd3b95526818a4.tar.bz2
gh-123476: Add support for TCP_QUICKACK socket setting to Windows (#123478)
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>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_socket.py26
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 7c607a8..628f806 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -6826,6 +6826,28 @@ class TestMacOSTCPFlags(unittest.TestCase):
def test_tcp_keepalive(self):
self.assertTrue(socket.TCP_KEEPALIVE)
+@unittest.skipUnless(hasattr(socket, 'TCP_QUICKACK'), 'need socket.TCP_QUICKACK')
+class TestQuickackFlag(unittest.TestCase):
+ def check_set_quickack(self, sock):
+ # quickack already true by default on some OS distributions
+ opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK)
+ if opt:
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK, 0)
+
+ opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK)
+ self.assertFalse(opt)
+
+ sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK, 1)
+
+ opt = sock.getsockopt(socket.IPPROTO_TCP, socket.TCP_QUICKACK)
+ self.assertTrue(opt)
+
+ def test_set_quickack(self):
+ sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM,
+ proto=socket.IPPROTO_TCP)
+ with sock:
+ self.check_set_quickack(sock)
+
@unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
class TestMSWindowsTCPFlags(unittest.TestCase):
@@ -6839,7 +6861,9 @@ class TestMSWindowsTCPFlags(unittest.TestCase):
'TCP_KEEPCNT',
# available starting with Windows 10 1709
'TCP_KEEPIDLE',
- 'TCP_KEEPINTVL'
+ 'TCP_KEEPINTVL',
+ # available starting with Windows 7 / Server 2008 R2
+ 'TCP_QUICKACK',
}
def test_new_tcp_flags(self):