On Oct 15, 2007, at 05:56, João Gonçalves wrote:
> I'm using these parameters:
> ((TTcpSrvClient *)Client)->LineMode = FALSE;//
> ((TTcpSrvClient *)Client)->LineEdit = TRUE;
> ((TTcpSrvClient *)Client)->OnDataAvailable = ClientDataAvailable;
> ((TTcpSrvClient *)Client)->OnBgException = ClientBgException;
> ((TTcpSrvClient *)Client)->ConnectTime = Now();
If you set LineMode=True, the OnDataAvailable event will trigger when
the entire data is received (and the line-delimiter is found). I think
this is what you want. Otherwise, it will trigger whenever the buffer
is full and there is *some* data, and it is up to you to piece it
together (this is what you have now).
That last one is intended for "streaming", where you are not expecting
a specific "line" of data, but a constant stream of data. If you are
sending commands, like other common Internet protocols, then you should
set LineMode to True. The default line-delimiter is #13#10
(CarriageReturn+LineFeed), like other Internet protocols, but you can
set it to whatever you want.
You also should set the LineLimit property to the maximum allowed
length of a line, otherwise your server may be vulnerable to DoS
attacks (since it will continue growing a buffer if no delimiter is
sent, and all memory may be consumed). When the LineLimit maximum is
reached, an exception is triggered (which you can handle in
OnLineLimitExceeded event).
dZ.
--
DZ-Jay [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
--
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