Article View: borland.public.cppbuilder.internet.socket
Article #3031Timeout Issues [Indy 9]
From: Darlington ADIBE
Date: Thu, 24 Nov 2005 23:27
Date: Thu, 24 Nov 2005 23:27
61 lines
3125 bytes
3125 bytes
My TCPClient/TCPServer appication taken shape, but i have some issues to
handle.
1. Timeout:
when a client calls ReadLn, and a timeout occures what should the client (my
code) do, should i clear the buffer cos when i send another command and
calls ReadLn, it comes back with the previous reply which off course makes
my application not to function well.
//SAMPLE
STDMETHODIMP TesemesAPIImpl::sendSMS(BSTR SMSText, BSTR ToNumber, BSTR*
pVal)
{
AnsiString cmd;
AnsiString Reply;
AnsiString SMS = StringReplace(SMSText, "\r\n", "\r", TReplaceFlags() <<
rfReplaceAll);
cmd.sprintf("SENDSMS#%s#%s#", SMS, AnsiString(ToNumber));
try
{
tcpp->WriteLn(cmd);
Reply = tcpp->ReadLn(LF, IdTimeoutDefault, -1);
if( Fetch(Reply , "#") == "SENDSMS") *pVal = WideString(Reply);
else if(tcpp->ReadLnTimedOut)
*pVal = WideString("ERR:Remote server timedout");
else *pVal = WideString("ERR:Unknown remote server response");
}
catch(Exception &e)
{
*pVal = WideString("ERR:" + e.Message);
return S_FALSE; /*Error(e.Message.c_str(), IID_IesemesAPI);*/
}
return S_OK;
}
Note: this unction is conatined within a COM Obj, Also note that i commented
the Error(e.Message.c_str(), IID_IesemesAPI); this because an error msg also
popup when a timeout occures.
So the question how best do I handle timeout when ReadLn is used to retrive
feedback, having in mind that the server might have successfully executed
the command, but just that the ACK back to the client did not arrive on
time.
When Error(e.Message.c_str(), IID_IesemesAPI);*/ is allowed to execute the
client goes into unknow state; it sometime discount from the server
2. (Mybe out off line) How best can one handle Exception in a COM (Automated
Lib in an ActiveX Lib).
Overview.
I have a server which i am trying to develop an API for third parties to us
in their code to communicate with my server application
base on methods called, the API send the reight cmd to the server, the
server execute the cmd and send back reply to the API, the API then return
the response to the calling Application.
Technical Details
Message-ID:
<43864c38@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!newscon02.news.prodigy.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,83a059fbd8c24375,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Darlington ADIBE" <bcb@triative.com> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Timeout Issues [Indy 9] Date: Fri, 25 Nov 2005 00:27:11 +0100 Lines: 64 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: <43864c38@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1132874808 83.229.68.10 (24 Nov 2005 15:26:48 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!newscon02.news.prodigy.com!prodigy.net!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail