//创建CPU数*2 + 2个线程 for i:=1 to si.dwNumberOfProcessors*2+2 do begin AThread := TRecvSendThread.Create( false ); AThread.CompletPort := FCompletPort;//告诉这个线程,你要去这个IOCP去访问数据 end;
procedure TRecvSendThread.Execute; var ...... begin while (not self.Terminated) do begin //查询IOCP状态(数据读写操作是否完成) GetQueuedCompletionStatus( CompletPort, BytesTransd, CompletKey, POVERLAPPED(pPerIoDat), TIME_OUT );