Article View: borland.public.cppbuilder.internet.socket
Article #4646Re: please help me..socket file transfer
From: Hans Galema
Date: Tue, 11 Jan 2005 21:12
Date: Tue, 11 Jan 2005 21:12
39 lines
2344 bytes
2344 bytes
Remy Lebeau (TeamB) wrote:
> Also, your code is leaking the file stream on both sides. You never close
> or free the streams.
There will be no leaking as deleting the stream is forbidden
if you use ->SendStream (stream ) for a TCustomWinSocket.
<from help>
bool __fastcall SendStream(Classes::TStream* AStream);
Note: The Stream passed as a parameter to SendStream becomes
๏ฟฝowned๏ฟฝ by the windows socket object. The Windows socket
object frees the stream when it is finished with it.
Do not attempt to free the stream after it has been passed
as a parameter.
</from help>
Question: Would the stream only be deleted if SendStream succeeded ?
One would think yes. As otherwise a next call for the
rest of the data in the stream was impossible.
> TFileStream* file = new TFileStream(OpenDialog1->FileName,
> fmOpenRead);
> try
> {
> if( !SendStream(ServerSocket1->Socket->Connections[0],
> file) )
> ShowMessage("Could not send file");
> }
> }
> __finally {
> delete file;
> }
Is that tested code ? It conflicts with the help.
Hans.
Technical Details
Message-ID:
<41e44159@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41e3b756@newsgroups.borland.com> <41e41d6a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,399582d307fda7fe X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,CP1252 Date: Tue, 11 Jan 2005 22:12:05 +0100 From: Hans Galema <notused@notused.nl> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: please help me..socket file transfer References: <41e3b756@newsgroups.borland.com> <41e41d6a$1@newsgroups.borland.com> In-Reply-To: <41e41d6a$1@newsgroups.borland.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 129.125.201.248 Message-ID: <41e44159@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1105477977 129.125.201.248 (11 Jan 2005 13:12:57 -0800) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!news.glorb.com!transit.nntp.hccnet.nl!transit1.nntp.hccnet.nl!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail