Cant Solve :(
Sent from [ProtonMail](https://protonmail.ch), encrypted email based in Switzerland. -------- Original Message -------- Subject: Re: [twsocket] WSocket Record and Stream Local Time: 2 de Janeiro de 2017 3:20 PM UTC Time: 2 de Janeiro de 2017 17:20 From: wilfr...@mestdagh.biz To: twsoc...@elists.org Hi, Do not activate the message pump in an event. ShowMessage() activate the message pump, so TWSocket will receive again and again because you are in a form waiting. If you wants to log for debugging purpose use WriteLn() or write to a file. Rgds, Wilfried Met vriendelijke groeten, Wilfried Mestdagh Op 02-01-17 om 17:58 schreef Fatimire: > Hi guys, im trayng to send a record with a stream size to send a image. > Example > PCtlCmd = ^TCtlCmd; > TCtlCmd = packed record > Cmd: Byte; > ImageSize: integer; > end; > > //SENDING > begin > MemoryStream := TMemoryStream.Create; > img1.Picture.Graphic.SaveToStream(MemoryStream); > MemoryStream.Seek(0, soFromBeginning); > FCCmd.Cmd := 10; > FCCmd.ImageSize := MemoryStream.Size; > WSocketServer1.Client[0].Send(@FCCmd, SizeOf(FCCmd)); > WSocketServer1.Client[0].Send(MemoryStream.Memory, MemoryStream.Size); > > > //receiving > procedure TForm1.WSocket1DataAvailable(Sender: TObject; ErrCode: Word); > var > nLen: Integer; > begin > FPos := 0; > nLen := WSocket1.Receive(@FCmd2[FPos], SizeOf(TCtlCmd2) - FPos); > if (nLen > 0) then > begin > Inc(FPos, nLen); > if (FPos = SizeOf(TCtlCmd2)) then > begin > FPos := 0; > try > case TCtlCmd2(FCmd2).cmd of > 10: > begin > ShowMessage(inttostr(TCtlCmd2(FCmd2).cmd)); > end; > end; > except end; > end; > end; > end; > But i receing the cmd 10 2 times, why ? > > > Sent from [ProtonMail](https://protonmail.ch), encrypted email based in > Switzerland. -- 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 -- 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