[pywin32-bugs] [ pywin32-Patches-1937527 ] win32file.ConnectEx patch
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2009-02-07 02:24:53
|
Patches item #1937527, was opened at 2008-04-08 19:32 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=1937527&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: ionel (ionel_mc) Assigned to: Nobody/Anonymous (nobody) Summary: win32file.ConnectEx patch Initial Comment: A patch for ConnectEx. called as follows: win32file.ConnectEx(sock, (host, port), overlappedobj [, bufferobj]) here's an example: import socket, win32file, pywintypes s = socket.socket() ol = pywintypes.OVERLAPPED() s.bind(('0.0.0.0', 0)) # connectex requires the socket be bound beforehand print win32file.ConnectEx(s, ("google.com", 80), ol, "GET / HTTP/1.1\r\n\r\n") print win32file.GetOverlappedResult(s.fileno(), ol, 1) ol = pywintypes.OVERLAPPED() buff = win32file.AllocateReadBuffer(20480) print win32file.WSARecv(s, buff, ol, 0) print win32file.GetOverlappedResult(s.fileno(), ol, 1) print buff I've tested this on win xp. I use getaddrinfo to process the (host, port) tuple. Please review. ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2009-02-07 12:58 Message: Roger has this in his py3k branch so its now merged to the trunk - thanks for your patience. ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2009-02-07 12:57 Message: Roger has this in his py3k branch so its now merged to the trunk - thanks for your patience. ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-05-09 10:36 Message: Logged In: YES user_id=1189761 Originator: YES To be completely honest I don't really know how to use the tuples returned from the socket.getaddrinfo - since they are very far from the C addrinfo struct I need to use in the ConnectEx call, also, i don't think the python function call overhead to get that addrinfo and make whatever conversions back to the struct is worth it. I would add some sort of demo but i need some suggestions (it seems I lack imagination right now). I don't cover the corner cases (like bad params) in the test_connectex. ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-05-09 10:25 Message: Logged In: YES user_id=1189761 Originator: YES File Added: test_connectex.py ---------------------------------------------------------------------- Comment By: Mark Hammond (mhammond) Date: 2008-05-05 20:33 Message: Logged In: YES user_id=14198 Originator: NO This looks pretty good. I'd probably prefer for getaddrinfo() to be called by the user of this function, and the necessary info passed in - is there a reason not to do that? Also, would you be so kind as to add something to the win32\test directory (and maybe even the win32\Demos directory :) that covers this? Thanks! ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-04-24 18:22 Message: Logged In: YES user_id=1189761 Originator: YES wops, forgot something File Added: win32file.i-4.patch ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-04-24 18:22 Message: Logged In: YES user_id=1189761 Originator: YES wops, forgot something File Added: win32file.i-4.patch ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-04-24 17:57 Message: Logged In: YES user_id=1189761 Originator: YES ok i've made some changes: i've moved the wsaioctl in the function body - the msdn docs didn't say if the pointer i'm getting is always the same - wsaioctl requires a wsainit before, i feel win32file is the wrong place to do that and i don't want to force users to import the socket module (for wsainit) before win32file still looking for some feedback on this one though. i've changed the buffer handling parts to use the 'buffer api' File Added: win32file.i-3.patch ---------------------------------------------------------------------- Comment By: ionel (ionel_mc) Date: 2008-04-24 17:57 Message: Logged In: YES user_id=1189761 Originator: YES ok i've made some changes: i've moved the wsaioctl in the function body - the msdn docs didn't say if the pointer i'm getting is always the same - wsaioctl requires a wsainit before, i feel win32file is the wrong place to do that and i don't want to force users to import the socket module (for wsainit) before win32file still looking for some feedback on this one though. i've changed the buffer handling parts to use the 'buffer api' File Added: win32file.i-3.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=1937527&group_id=78018 |