Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by Umberto Spagnoli
Mon, 12 Mar 2007 10:53
Bug in TIdTCPClient ???
Author: Umberto Spagnoli
Date: Mon, 12 Mar 2007 10:53
Date: Mon, 12 Mar 2007 10:53
21 lines
1480 bytes
1480 bytes
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
Re: Bug in TIdTCPClient ???
Author: Umberto Spagnoli
Date: Mon, 12 Mar 2007 16:51
Date: Mon, 12 Mar 2007 16:51
4 lines
1136 bytes
1136 bytes
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.
Re: Bug in TIdTCPClient ???
Author: Remy Lebeau (TeamB)
Date: Mon, 12 Mar 2007 17:28
Date: Mon, 12 Mar 2007 17:28
36 lines
1921 bytes
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads