F
fire.bruin
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TServerThread.Execute;
var
PerHandleData : LPPER_HANDLE_DATA;
PerIoData : LPPER_IO_OPERATION_DATA;
Flags : DWORD;
RecvBytes : DWORD;
begin
while not Terminated do
begin
Accept := WSAAccept(Listen, nil, nil, nil, 0);
PerHandleData := LPPER_HANDLE_DATA (GlobalAlloc(GPTR, sizeof(PER_HANDLE_DATA)));
PerHandleData.Socket := Accept;
CreateIoCompletionPort(Accept, CompletionPort, DWORD(PerHandleData), 0);
PerIoData := LPPER_IO_OPERATION_DATA(GlobalAlloc(GPTR, sizeof(PER_IO_OPERATION_DATA)));
ZeroMemory( @PerIoData.Overlapped, sizeof(OVERLAPPED));
PerIoData.BytesSEND := 0;
PerIoData.BytesRECV := 0;
PerIoData.DataBuf.len := DATA_BUFSIZE;
PerIoData.DataBuf.buf := @PerIoData.Buffer;
Flags:=0;
WSARecv(Accept, @(PerIoData.DataBuf), 1, @RecvBytes, @Flags,@(PerIoData.Overlapped), nil);
end;
end;
var
PerHandleData : LPPER_HANDLE_DATA;
PerIoData : LPPER_IO_OPERATION_DATA;
Flags : DWORD;
RecvBytes : DWORD;
begin
while not Terminated do
begin
Accept := WSAAccept(Listen, nil, nil, nil, 0);
PerHandleData := LPPER_HANDLE_DATA (GlobalAlloc(GPTR, sizeof(PER_HANDLE_DATA)));
PerHandleData.Socket := Accept;
CreateIoCompletionPort(Accept, CompletionPort, DWORD(PerHandleData), 0);
PerIoData := LPPER_IO_OPERATION_DATA(GlobalAlloc(GPTR, sizeof(PER_IO_OPERATION_DATA)));
ZeroMemory( @PerIoData.Overlapped, sizeof(OVERLAPPED));
PerIoData.BytesSEND := 0;
PerIoData.BytesRECV := 0;
PerIoData.DataBuf.len := DATA_BUFSIZE;
PerIoData.DataBuf.buf := @PerIoData.Buffer;
Flags:=0;
WSARecv(Accept, @(PerIoData.DataBuf), 1, @RecvBytes, @Flags,@(PerIoData.Overlapped), nil);
end;
end;