BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bug in TIdTCPClient ???

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket)
View previous topic :: View next topic  
Author Message
Umberto Spagnoli
Guest





PostPosted: Mon Mar 12, 2007 3:53 pm    Post subject: Bug in TIdTCPClient ??? Reply with quote



I'm using Indy components v. 9.0.50 bundled with BDS 2006.

When I send the ETX char (ASCII char 0x03) through a TIdTCPClient component,
I get 29 characters in my receive buffer. I tried with different methods
(WriteBuffer, WriteChar, WriteCardinal) but nothing changed. Is this a bug?
Is there any workaround?

Let's call ITcp the TIdTCPClient Component:

int len;
.......
ITcp->WriteInteger(3, true);
ioctlsocket ((SOCKET)ITcp->Socket->Binding->Handle, FIONREAD, &((unsigned
long)len));
......

len value is 29 after executing these lines


Thanks in advance for your replies
Umberto
Back to top
Umberto Spagnoli
Guest





PostPosted: Mon Mar 12, 2007 9:51 pm    Post subject: Re: Bug in TIdTCPClient ??? Reply with quote



Sorry.. my fault

With a network sniffer I found out that the reply comes from the server. I
was sure that the server didn't reply, but it wasn't true.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Mon Mar 12, 2007 10:28 pm    Post subject: Re: Bug in TIdTCPClient ??? Reply with quote



"Umberto Spagnoli" <jumby (AT) tiscali (DOT) it> wrote in message
news:45f530f7 (AT) newsgroups (DOT) borland.com...

Quote:
Is this a bug?

Not in TIdTCPSocket, no.

Quote:
Is there any workaround?

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

Quote:
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.

Quote:
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Socket) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.