Article View: borland.public.cppbuilder.internet.socket
Article #4399Indy TCP client conncted ?
From: Roberto Zais
Date: Mon, 21 Feb 2005 13:48
Date: Mon, 21 Feb 2005 13:48
56 lines
2551 bytes
2551 bytes
I have collected all useful informations in these newsgroup to migrate to
Indy9 ,
to read from a connection in the simplest way
but I have a little problem to detect if the connection is open .
I see from the leds that the connection establishes but the function
if(TCPClient->Connected()) //esito == true )
returns always false .
I' m beginner using Indy connection : it seems very simply ( too :-))
I' ve read that it is handled through exceptions .
Which is the simplest complete way to handle it ?
Can please someone give me recommendations ?
many thanks in advance
Roberto
I report some calls of my code :
TCPClient is encapsulated into a TThread
( should I use TIdThread?? Before now I ' ve only used to encapsulate an
indy SMTP component )
Connect- Disconnect - test connection
***** ----------------------------------------------
TCPClient->Connect();
TCPClient->Disconnect();
if(TCPClient->Connected()) //esito == true )
READ *** ( as recommended ) -----------------------------------
int size = TCPClient->ReadInteger(true);
if( size > 0 )
{
char *buf = new char[size];
TCPClient->ReadBuffer(buf, size);
// use of the buffer .
delete[] buf;
}
*** another variation ( 0x04 is the end character of the single message )
( is correct ?? )
Buffer = TCPClient->ReadLn("#04",2000,255);
Count = Buffer.Length();
if(Count)
{
use of the buffer
}
WRITE **** ----------------------------------------------------------
simply :
TCPClient->Write(ansi_temp_tx);
is correct? no test shoud be performed before ?
which exceptions could occur ??
Technical Details
Message-ID:
<4219e6b2$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,e9928c88cb4b1587,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Roberto Zais" <rzaiss@tiscali.it> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Indy TCP client conncted ? Date: Mon, 21 Feb 2005 14:48:29 +0100 Lines: 58 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 212.171.9.138 Message-ID: <4219e6b2$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1108993714 212.171.9.138 (21 Feb 2005 05:48:34 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail