🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Indy10 usage

#486
From: Remy Lebeau (TeamB)
Date: Tue, 04 Mar 2008 22:12
45 lines
2703 bytes
"Mike Ruskai" <BUTthannydI@DONTearthlinkLIKE.netSPAM> wrote in message 
news:tefrs3lpnfkk0arr2qa3vospikaj3j491h@4ax.com...

> You misunderstood.  I'm using normal socket code (e.g. connect(),
> select(), send(), recv(), etc.), not Indy.

You can't use TIdSocksInfo with a non-Indy connection, and there is no way 
to assign your own SOCKET handle to Indy's classes without re-writing them.

> recv() reads data up to the buffer length specified.

So does ReadBytes().

> ReadBytes() blocks forever until the specified data length is read,
> or the socket is closed.

Or until a ReadTimeout elapses, if specified.

> In other words, ReadBytes() is useless for a normal program

Not really.  If you want to just read what is currently available, up to but 
maybe less than the desired length, then simply call the ReadFromSource() 
method first and then adjust the length based on the InputBuffer's current 
size.  For example:

    IOHandler->ReadFromSource(true, 10, false);
    IOHandler->ReadBytes(buffer, min(1024, IOHandler->InputBuffer->Size));

> that doesn't know exactly how many bytes are going to be sent over the 
> socket.

Most protocols are designed to offer a way of knowing that.  But for those 
rare cases where it simply is not, then that is why the ReadFromSource() 
method and the InputBuffer property are publically accessible.

> As it happens, the current design uses text-only data on the control
> connection, so ReadLn() might work for command responses.  The
> data connection exists only for the duration of the transfer, so
> ReadBytes() may actually work out.

Sounds like you are reproducing exactly what the FTP protocol already does.


Gambit 
Technical Details
Message-ID: <47cdc920@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <ghsqs35tipni65rjlntjpl7hgi6f1bv1g8@4ax.com> <47cd89bb$1@newsgroups.borland.com> <tefrs3lpnfkk0arr2qa3vospikaj3j491h@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ea086d952e8cb041
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <ghsqs35tipni65rjlntjpl7hgi6f1bv1g8@4ax.com> <47cd89bb$1@newsgroups.borland.com> <tefrs3lpnfkk0arr2qa3vospikaj3j491h@4ax.com>
Subject: Re: Indy10 usage
Date: Tue, 4 Mar 2008 14:12:01 -0800
Lines: 47
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 207.178.157.90
Message-ID: <47cdc920@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1204668704 207.178.157.90 (4 Mar 2008 14:11:44 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail