You are right Michael.
If Simon's protocol is a character oriented protocol, he may use the "LineMode" 
feature of TWSocket to assemble received data in line and trigger 
OnDataAvailable event only for each complete line.

Embarcadero MVP

-----Message d'origine-----
De : TWSocket [] De la part de Michael 
Gasser (privat)
Envoyé : samedi 6 décembre 2014 13:35
À : ICS support mailing
Objet : Re: [twsocket] Sending font styles and colors over network


Hi Simon

did you read François Piettes posting, mainly the part about large "fragmented 

F.e. :
- If a client sends a large packet A to your server, your client may receive it 
(in your proc SocketServerDataAvailable) in several "small" 
- If a client machine sends several packages at once the data may arrive in 
several small packets. Example: C sends ABCDEF - the server may receive the 
data in four pieces: A1 (part 1 of A), then A2, then A3BCD1, then D2EF.

*You must implement an "incoming data buffer" for each connection (*Maybe you 
did... (?)), and then pass this buffered data to your parser.


Am 06.12.2014 12:18, schrieb Simon Lewis:
> Thanks for the Information am using TCP with  custom process here code
> procedure TLobbyServer.SocketServerDataAvailable(Sender: TObject;
> ErrCode: Word);
> begin
>   if ErrCode <> 0 then Exit;
>  with Sender as TWSocketClient do
>  begin
>    RunCommand(ReceiveStr, Sender as TWSocketClient);  end; end;
> procedure TLobbyServer.RunCommand(comdata: string; rSocket: 
> TWSocketClient);
> var
>  command: string;
> begin
>  comdata := DecodeStr(comdata);
>  while DecodeCommand(comdata, command, dat) do begin
>    case StrToIntDef(command, -1) of
>      00: begin
>           LobbyChatMsgs(dat[0], dat[1], dat[2], dat[3], 
> StrToInt(dat[4]), StrToInt(dat[5]), 
> TFontStyles(Byte(StrToInt(dat[6]))), rSocket);
>         end;
>    end;
> end;
> procedure TLobbyServer.LobbyChatMsgs(const LobbyID: String; const
> UserName: String; const Msg: String; const FontName: String;
> FontColor: TColor; FontSize: Integer; const FontStyle: TFontStyles;
> rSocket: TWSocketClient);
> begin
>  if Trim(UserName) = '' then
>  begin
>    Exit;
>   end else begin
>    SendLobbyCommand(LobbyID, 'š04œ'
>        + LobbyID + 'œ'
>        + UserName + 'œ'
>        + Msg + 'œ'
>        + FontName + 'œ'
>        + IntToStr(FontColor) + 'œ'
>        + IntToStr(FontSize) + 'œ'
>        + FontStyletoStr(FontStyle) + 'œ');
>    end;
> end;
> any way to improve it?, I know it be hard reading code with no having 
> all the correct codes so on also would you be able to supple me with a 
> simple image stream demo for video I been looking all over for one and 
> Never found it I would like to add video to my app one day ha.
> -----Original Message----- From: Simon Lewis
> Sent: Friday, December 05, 2014 6:53 PM
> To: TWSocket Archives
> Subject: Sending font styles and colors over network
> I know am flooding this news group with pointless questions but I 
> really need to know, am building a chat system and I want to send 
> basic text chat with font size/font color/font styles for each user am 
> doing this via strings and sending to server and back to client but I 
> noticed after a while and when more then a few users are typing the 
> text chat becomes unstable and incorrect font styles / colors and 
> sizes happen and only way to fix it is to re-login so am wondering 
> what would be best way to send the information over network so it 
> would be stable and reliable.
> Thanks

To unsubscribe or change your settings for TWSocket mailing list please goto
Visit our website at

To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at

Reply via email to