| View previous topic :: View next topic |
| Author |
Message |
Umberto Spagnoli Guest
|
Posted: Thu Mar 01, 2007 9:01 pm Post subject: About TIdTCPClient receive buffer... |
|
|
I'm using Indy components provided with BDS 2006 (v. 9.0.50)
How can I know how many bytes I currently received in the input buffer of my
TIdTCPClient component without reading the buffer?
Thanks in advance for your replies
Umberto |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Mar 01, 2007 10:05 pm Post subject: Re: About TIdTCPClient receive buffer... |
|
|
"Umberto Spagnoli" <jumby (AT) tiscali (DOT) it> wrote in message
news:45e6eac2$1 (AT) newsgroups (DOT) borland.com...
| Quote: | How can I know how many bytes I currently received in the
input buffer of my TIdTCPClient component without reading
the buffer?
|
TIdTCPClient derives from TIdTCPConnection, which has an InputBuffer
property, which in turn has a Size property.
Note that data is not put into the InputBuffer until you call one of
TIdTCPConnection's reading methods first. If you want to know how
many bytes are pending in the socket's internal receive buffer, then
you have to use the ioctlsocket() API function directly for that.
Gambit |
|
| Back to top |
|
 |
Umberto Spagnoli Guest
|
Posted: Fri Mar 02, 2007 12:13 am Post subject: Re: About TIdTCPClient receive buffer... |
|
|
Please, could you post a sample code using ioctlsocket() API function ?
I was not able to find any example....
Thanks in advance
| Quote: | If you want to know how
many bytes are pending in the socket's internal receive buffer, then
you have to use the ioctlsocket() API function directly for that.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri Mar 02, 2007 2:09 am Post subject: Re: About TIdTCPClient receive buffer... |
|
|
"Umberto Spagnoli" <jumby (AT) tiscali (DOT) it> wrote in message
news:45e717b9$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Please, could you post a sample code using ioctlsocket() API
function ? |
u_long bytes = 0;
if( ioctlsocket((SOCKET)IdTCPClient1->Socket->Binding->Handle,
FIONREAD, &bytes) == 0 )
{
// bytes specified the number of unread bytes in the socket's
internal buffer...
}
Typically, you should need to use the socket API directly when using
Indy, though. An alternative approach is to simply call the
connection's ReadFromStack() method to read all pending data into
Indy's InputBuffer, ie:
if( IdTCPClient1->ReadFromStack(true, 0, false) > 0 )
{
// pending data was read ...
}
Gambit |
|
| Back to top |
|
 |
Umberto Spagnoli Guest
|
Posted: Fri Mar 02, 2007 2:20 am Post subject: Re: About TIdTCPClient receive buffer... |
|
|
Great!
Thank you very much for your help
Umberto |
|
| Back to top |
|
 |
|