🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Using TIdTCPServer

#546
From: Peter
Date: Wed, 16 Jan 2008 14:01
27 lines
2175 bytes
Hello all...
here is my problem. I'm upgrading a bunch of products from Borland C++ Builder V5.0 to CodeGear C++ Builder 2007. All components used the old socket interface. I'm rewriting it to use TIdTCPServer component.

The code in the main module (not a form, it's actually a TService) is as follows:

iln_rcv_socket->DefaultPort=2020;
iln_rcv_socket->Active = true;

The onExecute handler does a few things, but basically it reads a TCP header like that:

pStream = new TIdTCPStream(AContext->Connection);
msg = pStream->Read(imageData->rcv_buffer, 20);

discards it, then reads two bytes to see how long the remaining transmission is:
msg = pStream->Read(imageData->rcv_buffer, 2);

calculates the length, and reads the rest:
msg = pStream->Read(imageData->rcv_buffer, calculated_length);

Now, the first two reads come back ok, but then the calculated length is different on each connection (and it's the same client, so I assume it should be the same), and the last read never comes back (that length is usually very large, like 40k+)

Any ideas on what's wrong??? and how to do it right???

P.S.
I have no control over the client connecting to the server, as we are communication with an IBM mainframe imaging system (ImagePlus), which is never fun :-)
 
Technical Details
Message-ID: <478e1c34$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,452e664b18b0b56c,start
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Peter" <piotrtrzeciak@yahoo.com>
Sender: "Peter" <piotrtrzeciak@yahoo.com>
Reply-To: "Peter" <piotrtrzeciak@yahoo.com>
Subject: Using TIdTCPServer
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 207.45.45.41     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <478e1c34$1@newsgroups.borland.com>
Date: 16 Jan 2008 07:01:08 -0700
X-Trace: newsgroups.borland.com 1200495668 207.105.83.66 (16 Jan 2008 07:01:08 -0700)
Lines: 27
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!feeder3.cambrium.nl!feed.tweaknews.nl!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.de!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail