summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorGabe Appleton <gabe@gabeappleton.me>2019-06-24 09:58:56 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-06-24 09:58:56 (GMT)
commit2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5 (patch)
tree68715ed4b442e07baa1bc057ea4703b3746abd08 /Misc
parent770847a7db33b3d4c451b42372b6942687aa6121 (diff)
downloadcpython-2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5.zip
cpython-2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5.tar.gz
cpython-2ac3bab2a6e1f9e17fc0c58a26e8425bb93cb0f5.tar.bz2
bpo-37345: Add formal UDPLITE support (GH-14258)
At the moment you can definitely use UDPLITE sockets on Linux systems, but it would be good if this support were formalized such that you can detect support at runtime easily. At the moment, to make and use a UDPLITE socket requires something like the following code: ``` >>> import socket >>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136) >>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 136) >>> a.bind(('localhost', 44444)) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 16) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 32) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.setsockopt(136, 10, 64) >>> b.sendto(b'test'*256, ('localhost', 44444)) ``` If you look at this through Wireshark, you can see that the packets are different in that the checksums and checksum coverages change. With the pull request that I am submitting momentarily, you could do the following code instead: ``` >>> import socket >>> a = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE) >>> b = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDPLITE) >>> a.bind(('localhost', 44444)) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(16) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(32) >>> b.sendto(b'test'*256, ('localhost', 44444)) >>> b.set_send_checksum_coverage(64) >>> b.sendto(b'test'*256, ('localhost', 44444)) ``` One can also detect support for UDPLITE just by checking ``` >>> hasattr(socket, 'IPPROTO_UDPLITE') ``` https://bugs.python.org/issue37345
Diffstat (limited to 'Misc')
-rw-r--r--Misc/NEWS.d/next/Library/2019-06-22-08-51-44.bpo-37345.o8XABX.rst6
1 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Library/2019-06-22-08-51-44.bpo-37345.o8XABX.rst b/Misc/NEWS.d/next/Library/2019-06-22-08-51-44.bpo-37345.o8XABX.rst
new file mode 100644
index 0000000..f43fd00
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-06-22-08-51-44.bpo-37345.o8XABX.rst
@@ -0,0 +1,6 @@
+Add formal support for UDPLITE sockets. Support was present before, but it
+is now easier to detect support with ``hasattr(socket, 'IPPROTO_UDPLITE')``
+and there are constants defined for each of the values needed:
+:py:obj:`socket.IPPROTO_UDPLITE`, :py:obj:`UDPLITE_SEND_CSCOV`, and
+:py:obj:`UDPLITE_RECV_CSCOV`.
+Patch by Gabe Appleton.