• Gabe Appleton's avatar
    bpo-37345: Add formal UDPLITE support (GH-14258) · 2ac3bab2
    Gabe Appleton yazdı
    
    
    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
    2ac3bab2
Adı
Son kayıt (commit)
Son güncelleme
..
_blake2 Loading commit data...
_ctypes Loading commit data...
_decimal Loading commit data...
_io Loading commit data...
_multiprocessing Loading commit data...
_sha3 Loading commit data...
_sqlite Loading commit data...
_ssl Loading commit data...
_xxtestfuzz Loading commit data...
cjkcodecs Loading commit data...
clinic Loading commit data...
expat Loading commit data...
README Loading commit data...
Setup Loading commit data...
_abc.c Loading commit data...
_asynciomodule.c Loading commit data...
_bisectmodule.c Loading commit data...
_bz2module.c Loading commit data...
_codecsmodule.c Loading commit data...
_collectionsmodule.c Loading commit data...
_contextvarsmodule.c Loading commit data...
_cryptmodule.c Loading commit data...
_csv.c Loading commit data...
_curses_panel.c Loading commit data...
_cursesmodule.c Loading commit data...
_datetimemodule.c Loading commit data...
_dbmmodule.c Loading commit data...
_elementtree.c Loading commit data...
_functoolsmodule.c Loading commit data...
_gdbmmodule.c Loading commit data...
_hashopenssl.c Loading commit data...
_heapqmodule.c Loading commit data...
_json.c Loading commit data...
_localemodule.c Loading commit data...
_lsprof.c Loading commit data...
_lzmamodule.c Loading commit data...
_math.c Loading commit data...
_math.h Loading commit data...
_opcode.c Loading commit data...
_operator.c Loading commit data...
_pickle.c Loading commit data...
_posixsubprocess.c Loading commit data...
_queuemodule.c Loading commit data...
_randommodule.c Loading commit data...
_scproxy.c Loading commit data...
_sre.c Loading commit data...
_ssl.c Loading commit data...
_ssl_data.h Loading commit data...
_stat.c Loading commit data...
_struct.c Loading commit data...
_testbuffer.c Loading commit data...
_testcapimodule.c Loading commit data...
_testimportmultiple.c Loading commit data...
_testinternalcapi.c Loading commit data...
_testmultiphase.c Loading commit data...
_threadmodule.c Loading commit data...
_tkinter.c Loading commit data...
_tracemalloc.c Loading commit data...
_uuidmodule.c Loading commit data...
_weakref.c Loading commit data...
_winapi.c Loading commit data...
_xxsubinterpretersmodule.c Loading commit data...
addrinfo.h Loading commit data...
arraymodule.c Loading commit data...
atexitmodule.c Loading commit data...
audioop.c Loading commit data...
binascii.c Loading commit data...
cmathmodule.c Loading commit data...
config.c.in Loading commit data...
errnomodule.c Loading commit data...
faulthandler.c Loading commit data...
fcntlmodule.c Loading commit data...
gc_weakref.txt Loading commit data...
gcmodule.c Loading commit data...
getaddrinfo.c Loading commit data...
getbuildinfo.c Loading commit data...
getnameinfo.c Loading commit data...
getpath.c Loading commit data...
grpmodule.c Loading commit data...
hashlib.h Loading commit data...
hashtable.c Loading commit data...
hashtable.h Loading commit data...
itertoolsmodule.c Loading commit data...
ld_so_aix.in Loading commit data...
main.c Loading commit data...
makesetup Loading commit data...
makexp_aix Loading commit data...
mathmodule.c Loading commit data...
md5module.c Loading commit data...
mmapmodule.c Loading commit data...
nismodule.c Loading commit data...
ossaudiodev.c Loading commit data...
overlapped.c Loading commit data...
parsermodule.c Loading commit data...
posixmodule.c Loading commit data...
posixmodule.h Loading commit data...
pwdmodule.c Loading commit data...
pyexpat.c Loading commit data...
readline.c Loading commit data...
resource.c Loading commit data...
rotatingtree.c Loading commit data...
rotatingtree.h Loading commit data...
selectmodule.c Loading commit data...
sha1module.c Loading commit data...
sha256module.c Loading commit data...
sha512module.c Loading commit data...
signalmodule.c Loading commit data...
socketmodule.c Loading commit data...
socketmodule.h Loading commit data...
spwdmodule.c Loading commit data...
sre.h Loading commit data...
sre_constants.h Loading commit data...
sre_lib.h Loading commit data...
symtablemodule.c Loading commit data...
syslogmodule.c Loading commit data...
termios.c Loading commit data...
testcapi_long.h Loading commit data...
timemodule.c Loading commit data...
tkappinit.c Loading commit data...
tkinter.h Loading commit data...
unicodedata.c Loading commit data...
unicodedata_db.h Loading commit data...
unicodename_db.h Loading commit data...
winreparse.h Loading commit data...
xxlimited.c Loading commit data...
xxmodule.c Loading commit data...
xxsubtype.c Loading commit data...
zlibmodule.c Loading commit data...