470,604 Members | 2,148 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,604 developers. It's quick & easy.

[win32all] GetQueuedCompletionStatus Problem

'''############################################### ##########################
GetQueuedCompletionStatus is return new OVERLAPPED instaed requested
OVERLAPPED. And OVERLAPPED.object member is lost.
and WSARecv Function increase Memory
Any clues anyone?

show test code
################################################## #######################'''

import win32file, win32event
import pywintypes
import socket

iocp = win32file.CreateIoCompletionPort(win32file.INVALID _HANDLE_VALUE,
None, 0, 0)

listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setblocking(0)
listen_socket.bind(('localhost', 9999))
listen_socket.listen(5)

accept_ol = pywintypes.OVERLAPPED()
accept_ol.object = "ACCEPT"
print 'accept_ol', accept_ol, accept_ol.object

accept_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
accept_socket.setblocking(0)
accept_buf = win32file.AllocateReadBuffer(64)
win32file.AcceptEx( listen_socket, accept_socket, accept_buf,
accept_ol)

win32file.CreateIoCompletionPort(listen_socket.fil eno(), iocp, 0, 0)
rc = 0
print 'listen loop'
while rc != 1:
(rc, nbytes, key, ol) = win32file.GetQueuedCompletionStatus(iocp,
win32event.INFINITE)
print 'GQCS --> ', rc, nbytes, key, ol, 'object:', getattr(ol,
'object', None)

recv_ol = pywintypes.OVERLAPPED()
recv_ol.object = "RECV"
print 'recv_ol', recv_ol, recv_ol.object

recv_buf = win32file.AllocateReadBuffer(1024)

win32file.CreateIoCompletionPort(accept_socket.fil eno(), iocp, 0, 0)
#win32file.WSARecv( accept_socket, recv_buf, recv_ol)
win32file.ReadFile( accept_socket.fileno(), recv_buf, recv_ol)

while 1:
(rc, nbytes, key, ol) = win32file.GetQueuedCompletionStatus(iocp,
win32event.INFINITE)
print 'GQCS --> ', rc, nbytes, key, ol, 'object:', getattr(ol,
'object', None)

# print recv_buf[:nbytes]
if (rc == 1):
# win32file.WSARecv( accept_socket, recv_buf, recv_ol)
win32file.ReadFile( accept_socket.fileno(), recv_buf, recv_ol)

'''############################################### ##########################
result

accept_ol <PyOVERLAPPED object at 0x00886F60> ACCEPT
listen loop
GQCS --> 1 0 0 <PyOVERLAPPED object at 0x009022B8> object: None
recv_ol <PyOVERLAPPED object at 0x009A1520> RECV
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009A1550> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009022B8> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009A1550> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009022B8> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009A1550> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009022B8> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009A1550> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009022B8> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009A1550> object: None
GQCS --> 1 1024 0 <PyOVERLAPPED object at 0x009022B8> object: None
GQCS --> 64 0 0 <PyOVERLAPPED object at 0x009022B8> object: None

################################################## #######################'''
Jul 18 '05 #1
0 1120

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.