 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Umberto Spagnoli Guest
|
Posted: Mon Mar 12, 2007 3:53 pm Post subject: Bug in TIdTCPClient ??? |
|
|
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
|
Posted: Mon Mar 12, 2007 9:51 pm Post subject: Re: Bug in TIdTCPClient ??? |
|
|
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
|
Posted: Mon Mar 12, 2007 10:28 pm Post subject: Re: Bug in TIdTCPClient ??? |
|
|
"Umberto Spagnoli" <jumby (AT) tiscali (DOT) it> wrote in message
news:45f530f7 (AT) newsgroups (DOT) borland.com...
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 |
|
 |
|
|
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
|
|