🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Indy TCP "Wait for Reply"

#3098
From: Darlington ADIBE
Date: Thu, 17 Nov 2005 18:58
79 lines
3312 bytes
Thank, looks perfect for what i needed. By the way 'Fetch' is it a BCB6
function or what?

Darl.


"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:437cc79a$1@newsgroups.borland.com...
>
> "Darlington ADIBE" <bcb@triative.com> wrote in message
> news:437c328b@newsgroups.borland.com...
>
> > Any profession advice on how to implement this "wait for reply" issue
>
> Indy already implements all of that for you.  Simply read from the socket
> immediately after you write to it.  The reading will not return until data
> is actually received, or a timeout/error occurs.  For example:
>
>     HRESULT __stdcall TMyComObjImpl::Authenticate(BSTR uid, BSTR pwd)
>     {
>         try
>         {
>             AnsiString Cmd;
>             AnsiString Response;
>             AnsiString Status;
>
>             Cmd.sprintf("#AUTHEN#%s#%s#", AnsiString(uid).c_str(),
> AnsiString(pwd).c_str());
>
>             TCPClient->Connect(5000);
>             try
>             {
>                 TCPClient->WriteLn(Cmd);
>                 Response = TCPClient->ReadLn(LF, IdTimeoutDefault; -1);
>
>                 Response.Delete(1,1);
>                 if( Fetch(Response, "#") != "AUTHEN" )
>                     throw Exception("Unknown response");
>
>                 Status = Fetch(Response, "#");
>                 if( Status != "OK" )
>                 {
>                     if( Status == "ERR" )
>                         throw Exception("Authentication failed: " +
> Fetch(Response, "#"));
>                     else
>                         throw Exception("Unknown response");
>                 }
>             }
>             catch(const Exception &)
>             {
>                 TCPClient->Disconnect();
>                 throw;
>             }
>         }
>         catch(const Exception &e)
>         {
>             return Error(e.Message, IID_IMyComObj);
>         }
>         return S_OK;
>     }
>
>     HRESULT __stdcall TMyComObjImpl::get_RTimeout(long *Result)
>     {
>         *Result = TCPClient->ReadTimeout;
>         return S_OK;
>     }
>
>     HRESULT __stdcall TMyComObjImpl::set_RTimeout(long Value)
>     {
>         TCPClient->ReadTimeout = Value;
>         return S_OK;
>     }
>
>
> Gambit
>
>
>
Technical Details
Message-ID: <437cd28f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeed.esat.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <437c328b@newsgroups.borland.com> <437cc79a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,187f889f070be6a7
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Darlington ADIBE" <bcb@triative.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <437c328b@newsgroups.borland.com> <437cc79a$1@newsgroups.borland.com>
Subject: Re: Indy TCP "Wait for Reply"
Date: Thu, 17 Nov 2005 19:58:31 +0100
Lines: 81
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: 83.229.68.10
Message-ID: <437cd28f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1132253839 83.229.68.10 (17 Nov 2005 10:57:19 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!newsfeed00.sul.t-online.de!t-online.de!newsfeed.esat.net!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail