Anton Sviridov wrote:
> 1) What's the meainng of SendBinString in Server, it is never used?
It's never used.
> What for do you use PutDataInSendBuffer?
It puts data into the send buffer without actually sending the data,
it's not required, however saves on internal call to socket.send.
2) I see alot of code to
> implement a data buffer which imho does the same things that socket
> buffer do.
It's similar, however needs less data copies, IMO.
> Isn't it necessary to construct such sophisticated logic
> every time when data parsing is needed? Moreover (maybe I haven't
> detected) what do you do, if FRcvBuf is going to be filled? That is,
>
> FRcvBuf: [_] [_] [_] [_] [D] [D] [D]
> |
> [_] - already parsed data
> [D] - data to be parsed
>> - current pointer
>
> and there are some more bytes to be received, but buffer is over...
> I've found only one Move(), but it's located inside if FReceiveMode =
> rmLine section, but no copying is done when mode is binary.
In mode rmBinary OnBinaryReceived will trigger. Data move is left
to the component user.
>
> 3) if FReceiveMode = rmLine then
> begin
> ...
> end;
>
> if FReceiveMode <> rmBinary then
> Exit;
>
> strange construction, concerning that FReceiveMode could be only
> rmLine or rmBinary... maybe if..else ?
It is because after TriggerLineReceived the receive mode may have
changed to rmBinary and I did not want to call ParseReceiveBuffer
recursively after TriggerLineReceived, it could be optimized though.
>
> 4) while (Length(RcvdLine) > 0) and
> (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
> RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
>
> while (Length(RcvdLine) > 0) and
> (RcvdLine[Length(RcvdLine)] in [#13, #10]) do
> SetLength(RcvdLine, Length(RcvdLine) - 1); ?
>
This code is from the (very old) TcpSrv demo which I did not
changed.
BTW: I uploaded the BinCliDemo to the SVN repository last week with
a small fix in:
function FindCrLf(Buf: PAnsiChar; Count: Integer): Integer;
begin
for Result := 0 to Count - 1 do
begin
if (Buf[Result] = #13) and (Result + 1 < Count) and
(Buf[Result + 1] = #10) then
Exit;
end;
Result := -1;
end;
--
Arno Garrels [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
> --
> Best regards, Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be