🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: a IdTCPClient solution

#3700
From: Roberto Zais
Date: Fri, 22 Jul 2005 10:17
67 lines
3267 bytes
First of all , please,  I have a question :  is  TCPClient->Disconnect();
innocuous  even if already disconnected , too ??
I didn' t find this information in the help.

> Better would be to not throw an exception at all.  Specify False instead
of
> True for the ARaiseExceptionOnTimeout parameter of ReadFromStack().  That
is
> what the earlier code sample was doing.

so, I have modified the code in this way :

try     {
        if(TCPClient->InputBuffer->Size  == 0 )
                size_readable = TCPClient->ReadFromStack(true,100,false);
              else
                size_readable = TCPClient->InputBuffer->Size;
        }
       catch(const Exception& e){
          String sbuf = String(e.ClassName()) + " " + e.Message;
          MessageText = sbuf;    //  for only eventually debug info
          return;                         // all exception in this phase :
return (wait loop)
                                            //  ( there is a global timeout
on the RX operation)

          }
if(!size_readable)
        return;

else:  ......  acquisition of data

Now, I don' t experiment(by debugging) any return by exception: which other
exception are possible , except rxtimeout?
I remember at the beginning, I set the try-catch because it seemed that in
presence of a bad condition ( typically
read timeout)  the size returned  by TCPClient->ReadFromStack was bad and I
got blockings and bad
results .
What does it happen if I remove the try-catch and set
TCPClient->ReadFromStack(true,100,false);  ?
Is size_readable really  reliable ?


>
> How EXACTLY are your packets actually formatted?  It doesn't look like you
> are taking the advice of the earlier code sample:
>
>     "I would strongly recommend that you prefix your packets with the
actual
> size of the packets.  Then you don't have to limit your buffer size during
> reading, and can send small and large packets alike"
>

Yes, the only reason is that I fear disalignment . But ,really ,there is not
a difference concerning disalignment .
My packets begin with 0x16 and end with 0x4  all other is ASCII char.
When the first byte is lost is lost and the re align procedure is the same .
More, through a TCP conn.
nothing should be lost.

On the whole, is this solution  the more common and fast?
Using streams may be better or not ?

Thanks, very much , for your help

Roberto
Technical Details
Message-ID: <42e0c5b2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <42e010be$1@newsgroups.borland.com> <42e02116@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,a84606e83349b98f
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Roberto Zais" <rzaiss@tiscali.it>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <42e010be$1@newsgroups.borland.com> <42e02116@newsgroups.borland.com>
Subject: Re: a IdTCPClient solution
Date: Fri, 22 Jul 2005 12:17:03 +0200
Lines: 69
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
NNTP-Posting-Host: 212.171.10.136
Message-ID: <42e0c5b2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1122026930 212.171.10.136 (22 Jul 2005 03:08:50 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail