Article View: borland.public.cppbuilder.internet.socket
Article #2569Re: Inactivity timeouts in sockets?
From: Martin
Date: Mon, 27 Mar 2006 20:51
Date: Mon, 27 Mar 2006 20:51
69 lines
3244 bytes
3244 bytes
Remy Lebeau (TeamB) wrote:
> "Martin" <dev@no.comppromed.spam.com> wrote in message
> news:44281b29$1@newsgroups.borland.com...
>
>
>>The connection that gives me the problem is one that has periods
>>where nothing is sent/receive for more than 20 minutes.
>
>
> Sockets themselves do not have any problems with idle periods. They don't
> care at all whether data is being transmitted frequently or not. So any
> problems you are having are likely caused by problems in your own code that
> is managing the sockets.
>
>
>>The socket is still connected (no disconnect events or errors), but
>>later on we find that the other side tried to send something that wasn't
>>received by our app.
>
>
> What does your actual code look like? Since you are using non-blocking
> sockets, my first guess would be that you are not completely clearing the
> socket's inbound buffer when data arrives, thus the socket eventually begins
> losing notifications when new data arrives. When data arrives, you have to
> read ALL of it at that moment, into your own buffer. You should not leave
> data unread in the socket in between events.
>
>
> Gambit
>
>
I don't think I'm leaving anything in the input
buffer. Here's the OnRead event:
void __fastcall socketClass::onRead( TObject
*Sender, TCustomWinSocket *Socket)
{
char buf[ 4096];
for (;;)
{
int numBytes = Socket->ReceiveBuf( buf,
sizeof( buf));
if (numBytes <= 0)
break;
if (cfg.comDiag > 1)
audit( HERE, "%s %s:onRead - Recving
%d bytes\n",
currentTime(), this->sktId,
numBytes);
this->inBuf->writeData( buf, numBytes);
}
} /* socketClass::onRead() */
inBuf is a ring buffer class that we wrote years
ago. It stores the data until the app has a chance
to get around to it (within 0.5 sec.). It's
possible that the ring buffer is messing with me
but it's been in use longer than the underlying
socket stuff. I'm double checking tonight to see
if we're getting the audit info from the read
event. Unfortunately, this problem only happens
overnight.
Marty
Technical Details
Message-ID:
<44285053$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44281b29$1@newsgroups.borland.com> <44282b0d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,11a7fa37087eb9c X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Mon, 27 Mar 2006 12:51:31 -0800 From: Martin <dev@no.comppromed.spam.com> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.11) Gecko/20050728 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: Inactivity timeouts in sockets? References: <44281b29$1@newsgroups.borland.com> <44282b0d$1@newsgroups.borland.com> In-Reply-To: <44282b0d$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 209.204.181.224 Message-ID: <44285053$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1143492691 209.204.181.224 (27 Mar 2006 12:51:31 -0700) Lines: 69 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail