Always is needed use the OnDataSent event ?
I need only transfer the tmemorystream off a Timage1 to Timage2 over twsocket.



Sent from [ProtonMail](https://protonmail.ch), encrypted email based in 
Switzerland.



-------- Original Message --------
Subject: Re: [twsocket] TWsocket transfer TmemoryStream
Local Time: 5 de Dezembro de 2016 5:31 PM
UTC Time: 5 de Dezembro de 2016 19:31
From: fatim...@protonmail.com
To: ICS support mailing <twsocket@lists.elists.org>

procedure TForm1.SendClick(Sender: TObject);
var
Buffer: array [1..BLOCK_SIZE] of char;
Count: Integer;
MemoryStream : TMemoryStream;
begin
try
MemoryStream := TMemoryStream.Create;
img1.Picture.Graphic.SaveToStream(MemoryStream);
MemoryStream.Seek(0, soFromBeginning);
WSocketServer1.Client[0].SendStr(IntToStr(MemoryStream.Size) + #13#10);

Count := MemoryStream.Read(Buffer[1], BLOCK_SIZE);
if Count > 0 then
WSocketServer1.Client[0].Send(@Buffer[1], Count);
if Count < BLOCK_SIZE then ShowMessage('Sended');
except end;

end;

Its Ok ?


Sent from [ProtonMail](https://protonmail.ch), encrypted email based in 
Switzerland.



-------- Original Message --------
Subject: Re: [twsocket] TWsocket transfer TmemoryStream
Local Time: 5 de Dezembro de 2016 3:19 PM
UTC Time: 5 de Dezembro de 2016 17:19
From: an...@magsys.co.uk
To: twsocket@lists.elists.org

> I need help to send text and stream in same socket

Sending text and stream data is simple, just use Send, although if your
stream is larger than a few kilobytes you need to send it in chunks,
check whether it's been sent, then send the next chunk.

This is how the HTTP client component works.

Receiving mixed text and stream data is much harder, because you don't
generally know where one stops and the other starts. So you design a
protocol, an example being HTTP again, where a blank line says text
stops and stream starts, the stream length being content-length long or
when the socket closes.

Angus

--
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

Reply via email to