The Overlapped.TransmitFile()
method is implemented in Python 3.7+ in the _overlapped
extension module. It’s undocumented and only intended for internal use in the standard library. That said, it’s technically possible to use it outside of the asyncio
module, but it’s awkward. For example:
>>> import socket, msvcrt, _overlapped
>>> f = open('spam.txt', 'wb+')
>>> f.write(b'eggs')
4
>>> f.flush(); f.seek(0)
0
>>> h = msvcrt.get_osfhandle(f.fileno())
>>> sr, sw = socket.socketpair()
>>> ov = _overlapped.Overlapped()
>>> ov.TransmitFile(sw.fileno(), h, 0, 0, 4, 4, 0)
>>> ov.getresult(True)
4
>>> sr.recv(4)
b'eggs'