Hello,

Could you look at the new code below:

procedure TWebConnection.ConnectionDataSentISAPI(Sender : TObject;
Error : WORD);
begin
        sendError := Error;
        sendComplete := true;
end;

function TWebConnection.SendSync(Data: String): boolean;
begin
        Result := SendSync(PChar(Data), Length(Data));
end;

function TWebConnection.SendSync(Data: PChar; DataLen: Integer): boolean;
var
        Count: integer;
        error: integer;
        offset: integer;
        Msg: TMsg;
begin
        packetLen := DataLen;
        packetSentLen := 0;
        offset := 0;
        sendComplete := false;

        if FTerminated or
        (State <> wsConnected) then
        begin
                Result := false;
                Exit;
        end;

        while (offset < DataLen) do
        begin
                sendError := 0;
                sendComplete := false;
                Count := Send(Data + offset, DataLen - offset);

                Result := Count > 0;

                if not Result then
                begin
                        error := WSAGetLastError();
                        Result := false;
                        Exit;
                end;

                while((not FTerminated) and (not sendComplete) and
(State = wsConnected)) do
                begin
                      if GetMessage(Msg, 0, 0, 0) = true then
                      begin
                             DispatchMessage(Msg);
                      end;
                end;

                DataSent := DataSent + Count;
                offset := offset + Count;
        end;

        Result := sendError <> 0;

        if(FTerminated or
          (State <> wsConnected)
          ) then
        begin
                Result := false;
        end;
end;

It works with debug compile when even NO breakpoints are set but does
not work with release build of the server. FYI, here is the hierarchy
of the classes:

THttpConnection-->TWebConnection->httpServerClientClass

Best Regards,

SZ

On 11/21/06, Francois PIETTE <[EMAIL PROTECTED]> wrote:
> >I do not think the issue understood the same here and there. Why is
> > the Count = -1 then?
>
> When you call Send, passing a number of bytes and send is not able to send
> it without blocking and non-blocking mode is active, then send returns -1 to
> tell you it can't do what you asked. Nothing is sent. WSAGetLastError tells
> you what exactly happended.
>
> > What should one do to have the sync method work?
>
> ICS doesn't use blocking mode. Trying to change that without knowing exactly
> what you are doing will result in unexpected results - as you can see.
>
> You'd better design your code to use non blocking mode.
> If ISAPI is what you want, have a look at IcsIsap1.pas in the demos.
>
> --
> Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html
> --
> [EMAIL PROTECTED]
> http://www.overbyte.be
>
>
> --
> 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
>
-- 
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

Reply via email to