Menu

#84 win32file.TransmitFile and ConnectEx patch

closed-fixed
nobody
None
5
2014-08-14
2008-05-12
ionel
No

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 :)

Discussion

<< < 1 2 (Page 2 of 2)
  • ionel

    ionel - 2008-12-01

    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?

     
  • Mark Hammond

    Mark Hammond - 2008-12-01

    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

     
  • Mark Hammond

    Mark Hammond - 2009-01-25

    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

     
  • Mark Hammond

    Mark Hammond - 2009-01-25
    • status: open --> closed-fixed
     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.