Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : TIdIPMCastServer and Client problem when sending binary data using tIDBytes and
| Subject: | TIdIPMCastServer and Client problem when sending binary data using tIDBytes and |
| Posted by: | "Sotiris Karanasios" (karana..@gmail.com) |
| Date: | Thu, 1 Nov 2007 15:19:26 |
Hi there all koderz,
I have done a thorough search on the internet regarding sending binary data
over the TIdIPMCastServer to the TIdIPMCastClient with no success.
I am using a form wtih both Client and Server components (I have also tried
it with different projects, one with Server and one with client).
On my form I have two buttons, one to send simple text and one binary data.
The simple text button code is as follows below:
procedure TForm2.Button2Click(Sender: TObject);
begin
MCastServer.Send('hi');
end;
By Binary Send button has the following code
procedure TForm2.Button1Click(Sender: TObject);
var mstream : TFileStream;
MemStream : TMemoryStream;
MyBuffer : TIdBytes;
begin
MStream := TFileStream.Create('d:\0001.png',fmOpenRead);
MemStream := TMemoryStream.Create;
MStream.Position := 0;
MemStream.CopyFrom( MStream, Mstream.Size);
//Debug
Memo1.Lines.Add('MemStream Size:' +IntTostr(MemStream.Size) );
Memo1.Lines.Add('FilStream Size:' +IntToStr(MemStream.Size) );
MyBuffer := RawToBytes( MemStream, MemStream.Size);
Memo1.Lines.Add('BufferSize:'+IntToStr(SizeOf(MyBuffer))+'
'+IntToStr(Length(MyBuffer))+' '+IntToStr(MyBuffer[0]));
MCastServer.Send( MyBuffer );
MStream.Free;
MemStream.Free;
end;
and the receive client code is as follows
procedure TForm2.MCastClientIPMCastRead(Sender: TObject; const AData:
TBytes;
ABinding: TIdSocketHandle);
begin
if SizeOf(Adata) > 0 then
Memo1.Lines.Add('Received Something');
end;
Now the problem is that I can sent as many text messages as I want. Once I
press the BinarySend button the MCastClientIPMCastRead event is not
triggered. Nevertheless after I press once the BinarySend button the
TextSend Button also stops to work (the MCastClientIPMCastRead is not
triggered).
Any one out there can help ? I am running Delphi 2007 with Indy (I think its
v10) that came with the Delphi.
I have also tried to run the application broken into two projects one client
with code as shown above and one server with the same code as shown above
but the results where exactly the same.
Any suggestions and examples ? I am trying to send small datafiles.
Thank you all,
Sotiris/karanaso/Greece