🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Bug in TIdTCPClient ???

#1228
From: Remy Lebeau (TeamB)
Date: Mon, 12 Mar 2007 17:28
36 lines
1921 bytes
"Umberto Spagnoli" <jumby@tiscali.it> wrote in message
news:45f530f7@newsgroups.borland.com...

> Is this a bug?

Not in TIdTCPSocket, no.

> Is there any workaround?

Why do you think it is a problem?  Are you not expecting the server to
send you any data?

> ioctlsocket ((SOCKET)ITcp->Socket->Binding->Handle, FIONREAD,
&((unsigned
> long)len));

Why are you calling ioctlsocket() directly in the first place?  If you
want TIdTCPClient to check how many bytes are available from the
server without knowing ahead of time how many to expect, then you
should be calling its ReadFromStack() method instead, ie:

    ITcp->WriteInteger(3, true);
    int len = ITcp->ReadFromStack(true, 0, false);
    // len number of bytes have been placed into the InputBuffer if
any were available.

> len value is 29 after executing these lines

You are not checking the return value of ioctlsocket(), and you are
not initializing the len variable, so it is possible that the variable
contains some random value off of the stack that ioctlsocket() did not
overwrite.


Gambit
Technical Details
Message-ID: <45f580f6@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45f530f7@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ee03d59ef261bda0
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <45f530f7@newsgroups.borland.com>
Subject: Re: Bug in TIdTCPClient ???
Date: Mon, 12 Mar 2007 09:28:45 -0800
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.83.34.171
Message-ID: <45f580f6@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1173717238 75.83.34.171 (12 Mar 2007 09:33:58 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail