P
panxiaosen
Unregistered / Unconfirmed
GUEST, unregistred user!
我的客户端连接上服务器之后,先用普通的RECV和SEND进行了一些验证操作之后,我再把她捆绑到完成端口上的.代码如下,但是我只要把那句Sleep(2000); 去了,就会发生错误,加上去就是可以的,,,请问各位这是为什么呢??
CreateIoCompletionPort(LPGAME.GameSocket, FCompletPort, Cardinal(LPGAME), 0);
Sleep(2000); //不加上这个就不能正常工作......
New(pPerIoDat);
FillChar(pPerIoDat^.Overlapped, sizeof(OVERLAPPED), 0);
pPerIoDat^.wsaBuffer.len := MAX_BUFSIZE;
pPerIoDat^.wsaBuffer.buf := pPerIoDat^.Buffer;
Flags := 0;
if WSARecv(LPGAME.GameSocket, @(pPerIoDat^.wsabuffer), 1, BytesRecv, Flags, @(pPerIoDat^.Overlapped), nil) = socket_error then
if GetLastError <> error_io_pending then
goto err;
CreateIoCompletionPort(LPGAME.GameSocket, FCompletPort, Cardinal(LPGAME), 0);
Sleep(2000); //不加上这个就不能正常工作......
New(pPerIoDat);
FillChar(pPerIoDat^.Overlapped, sizeof(OVERLAPPED), 0);
pPerIoDat^.wsaBuffer.len := MAX_BUFSIZE;
pPerIoDat^.wsaBuffer.buf := pPerIoDat^.Buffer;
Flags := 0;
if WSARecv(LPGAME.GameSocket, @(pPerIoDat^.wsabuffer), 1, BytesRecv, Flags, @(pPerIoDat^.Overlapped), nil) = socket_error then
if GetLastError <> error_io_pending then
goto err;