🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4366

Using TClientSocket &SendStream to transfer floats?

#4366
From: Robertwf
Date: Tue, 15 Feb 2005 22:20
37 lines
2386 bytes
I am writing a server application in Builder 6.0

I have a Data Module class that contains a pointer to a TClientSocket.
I want to create a function that is called to send an array of floats to the Server.
I dont understand the use of the SaveToStream method:
     SaveToStream(TStream* Stream);
I have seen code that uses a pointer to a TBitMap, but I have not been able to 
convert that knowledge to my needs.

From the Help it looks like I need to:
1) create a TMemoryStream
2) use the SaveToStream method to write into this new stream
3) set the position of the stream to 0
4) use the Write method of the stream to write my array
5) set the position of the stream to 0
6) use the SendStream method of TClientSocket to send the data to the Server

Here is an example of code in which I create the data matrix rather than it being 
provided to my function
 void foo();
{
AlgTech::Math::Matrix<double,2,2> test_float(1.0,2.0,3.0,4.0); //creates a 2x2 array

TMemoryStream* data_ms = new TMemoryStream();
  ?what_goes_here?->SaveToStream(data_ms);  // <------my problem

  data_ms->Position = 0;
  data_ms->Write((const void*)&test_float,sizeof(float) * test_float.size());
  data_ms->Position = 0;

  ClientSocket1->Socket->SendStream(data_ms);
 delete data_ms;
}

Thanks for your time.
Robert
Technical Details
Message-ID: <421275a3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,30e232a5d68591b8,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Robertwf" <robert.w.fuentes@lmco.com>
Sender: "Robertwf" <robert.w.fuentes@lmco.com>
Reply-To: "Robertwf" <robert.w.fuentes@lmco.com>
Subject: Using TClientSocket &SendStream to transfer floats?
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 192.91.147.36     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <421275a3$1@newsgroups.borland.com>
Date: 15 Feb 2005 14:20:19 -0800
X-Trace: newsgroups.borland.com 1108506019 207.105.83.66 (15 Feb 2005 14:20:19 -0800)
Lines: 37
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!news-out.nntp.be!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail