🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Reading Binary Data

#5094
From: Paul Machiaverna
Date: Fri, 15 Oct 2004 20:42
22 lines
1794 bytes
I'm using INDY 9 in a server application and would like to know the preferred method of reading binary data from a client.  I've been using this code (in the OnExecute method):

AnsiString lsReadData;
int liNumBytes;

// If there is data ready to be read,
if ( AThread->Connection->Socket->Binding->Readable( 1 ) )
{
    // Read it.
    lsReadData = AThread->Connection->CurrentReadBuffer();
    liNumBytes = isReadData.Length();

    // Process the bytes.
    ProcessData( (BYTE*)(lsReadData.c_str()), liNumBytes );
}

ProcessData feeds each byte through a state machine to determine the end of data marker.

The problem is that when I try shutting down the socket, the connection enters a TIME_WAIT state instead of closing and releasing.  It appears that this has something to do with the way I'm reading the data because if I comment out the read the connection closes immediately.

Paul Mac
Technical Details
Message-ID: <4170363b$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!easynet-monga!easynet.net!news.clara.net!wagner.news.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,86d2a32b454a1312,start
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Sender: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Reply-To: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Subject: Reading Binary Data
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 130.36.11.140     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4170363b$1@newsgroups.borland.com>
Date: 15 Oct 2004 13:42:35 -0700
X-Trace: newsgroups.borland.com 1097872955 207.105.83.66 (15 Oct 2004 13:42:35 -0700)
Lines: 24
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!easynet-monga!easynet.net!news.clara.net!wagner.news.clara.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail