win32file.TransmitFile and ConnectEx patch
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
sample usage:
import win32file, socket, pywintypes
s = socket.socket()
f = file('somefile','rb')
s.connect(('192.168.111.128',10002))
ol = pywintypes.OVERLAPPED()
print win32file.TransmitFile(s, win32file._get_osfhandle(f.fileno()), 0, 0, ol, 0, "prepended data", "appended data")
length = win32file.GetOverlappedResult(s.fileno(), ol, 1)
print length
I hope I haven't done the wrong thing but for the sake of simplicity I'm providing a patch the includes the previous ConnectEx patch (hopefully it'll get accepted :)
I don't see any necessary changes to the patch as one can easily use as a workaround the family-specific addresses from the sockaddr in the tuple from getaddrinfo
suppose, some addrinfo_i_want in socket.getaddrinfo(*someaddr)
i would use:
win32file.ConnectEx(sock, addrinfo_i_want[4], overlap)
Am I missing something?
Thanks for your patience - I see what you mean and can't argue with it <wink>, so yeah, I'm inclined to agree its pretty good to go. I'd like to wait for Roger to respond if that's OK, but I'll do something before the next release.
A minor nit, the format string with "OO:getaddrinfo" isn't correct - the Python exception would report the error was in getaddrinfo, which it's not. An option would be to just parse the args once - the top format string changes from a simple "O" for the addrinfo to a "(OO)", and the second PyArg_ParseTuple can die. I'm mentioning this mainly so I remember when applying it (but obviously feel free to add a new patch:)
Thanks
Thank you both!
Checking in win32/src/win32file.i;
new revision: 1.98; previous revision: 1.97
Checking in win32/test/test_win32file.py;
new revision: 1.28; previous revision: 1.27