Article View: borland.public.cppbuilder.internet.socket
Article #2999Re: TCP
From: Jesper
Date: Sat, 10 Dec 2005 13:02
Date: Sat, 10 Dec 2005 13:02
81 lines
3254 bytes
3254 bytes
Thanx for all the help!
I will try it anc come back and ask more questions later! :-)
And I wont SPAM this time, promise :-)
Cheerz
/J
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> skrev i meddelandet
news:439a03e0$1@newsgroups.borland.com...
>
> "Jesper" <jesper@safholm.com> wrote in message
> news:4399dee8@newsgroups.borland.com...
>
>> IdTCPClient1->BoundIP = Edit1->Text; //The IP of the other computer
>
> That is not correct. The BoundIP property is used to specify the IP of
> the
> *local* machine that the socket will bind to. Use the Host property
> instead
> to specify the IP of the *remote* machine that the server is running on.
>
>> IdTCPClient1->WriteFile("test\\test.txt");
>
> I would not suggest using WriteFile() in this situation. It does not
> provide any means of telling the other party how much data is actually
> being
> sent. I would suggest using WriteStream() instead, ie:
>
> TFileStream *FStream = new TFileStream("test\\test.txt", fmOpenRead |
> fmShareDenyWrite);
> try
> {
> IdTCPClient.WriteStream(FStream, true, true, 0);
> }
> __finally {
> delete FStream;
> }
>
> Then you can use ReadStream() on the TIdTCPServer to receive the data.
> ReadStream() can read the stream size ahead of time in order to optimize
> the
> reading:
>
> void __fastcall TForm1::IdTCPServer1Connect(TIdPeerThread *AThread)
> {
> AnsiString FileName = "some file name here";
> TFileStream *FStream = new TFileStream(FileName, fmCreate);
> try
> {
> try
> {
> AThread->Connection->ReadStream(FStream, -1, false);
> }
> __finally
> {
> delete FStream;
> }
> }
> catch(const Exception &)
> {
> DeleteFile(FileName);
> }
> }
>
>> if(IdTCPClient1->Connected() == true)
>
> Why are you checking that after calling WriteFile() instead of after
> calling
> Connect()?
>
> In any case, you don't need to check it at all anyway since Connect() will
> throw an exception if it fails.
>
>> My problem is IdTCPClient1->WriteFile.
>
> What is your actual problem with it? Please be more specific.
>
>
> Gambit
>
>
Technical Details
Message-ID:
<439ad1a6@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4399dee8@newsgroups.borland.com> <439a03e0$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ae2c1a9c997cef31 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Jesper" <jesper@safholm.com> From: "Jesper" <jesper@safholm.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <4399dee8@newsgroups.borland.com> <439a03e0$1@newsgroups.borland.com> Subject: Re: TCP Date: Sat, 10 Dec 2005 14:02:33 +0100 Lines: 83 Organization: Blackhole Productions X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 213.164.198.226 Message-ID: <439ad1a6@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1134219686 213.164.198.226 (10 Dec 2005 05:01:26 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news2.volia.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail