Hello, I know most of you are very inclined to say that "sync is no good!" but it is not that simple. I have licensed code from BPDX.com for ISAPI and ISAPI filters andt hese units (more than 100k!) need to read, write and alter header or an existing THttpConnection derivative class. Starting with writing, I wrote the below function:
function TWebConnection.SendSync(Data: PChar; DataLen: Integer): integer; var Count: integer; begin if FTerminated then begin Result := 0; Exit; end; fDataLen := DataLen; fTotalSentDataLen := 0; //OldDataAvailable := FOnDataAvailable; //OldSendData := FOnSendData; //OldDataSent := FOnDataSent; FOnDataAvailable := InternalDataAvailable; FOnSendData := ConnectionSendDataISAPI; FOnDataSent := nil; DoneFlag := false; ISAPIDownloadPauseDelay; Count := Send(Data, DataLen); Result := Count; if (Result = 0) or FTerminated then begin Result := 0; Exit; end; if WaitUntilReady(DoneFlag) <> 0 then Result := 0 else begin DataSent := DataSent + Count; FOnDataAvailable := nil; FOnSendData := nil; FOnDataSent := nil; end; end; InternalDataAvailable, and WaitUntilReady are the same as Francois'. procedure TWebConnection.ConnectionSendDataISAPI(Sender: TObject; BytesSent: Integer); begin fTotalSentDataLen := fTotalSentDataLen + BytesSent; if fTotalSentDataLen >= fDataLen then DoneFlag := true; end; So far so good but when I launch many client threads to the PHP5ISAPI.dll script, in a few seconds it gives access violation in kernel32.dll! I think considering also the logic of ISAPI filters, we still need sync functions in parallel. Do you see the bug above? Regards, SubZ -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be