Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages
Started by fabrice
Tue, 01 Aug 2006 09:37
indy 9 and TidTcpServer
Author: fabrice
Date: Tue, 01 Aug 2006 09:37
Date: Tue, 01 Aug 2006 09:37
24 lines
1350 bytes
1350 bytes
Hello I use indy 9 and TidTcpServer component. Before to read using "AThread->Connection->Socket->Recv(ptr,len)" with ptr a pointer to a buffer and len the number of bytes to read from the connection. How can I know exactly the bytes that has been received in the socket ? I would like to pass the good value in "len" and adjust the buffer size of the receipt buffer Is a method like ReceiveLength() exist with TidTcpServer? Thanks for the help !
Re: indy 9 and TidTcpServer
Author: Remy Lebeau (TeamB)
Date: Tue, 01 Aug 2006 20:19
Date: Tue, 01 Aug 2006 20:19
37 lines
2331 bytes
2331 bytes
"fabrice" <f.marcantuoni@splin-rd.com> wrote in message
news:44cf20f5$1@newsgroups.borland.com...
> Before to read using "AThread->Connection->Socket->Recv(ptr,len)"
Do NOT call Recv() directly! Use the reading methods from TIdTCPConnection
instead, such as ReadBuffer():
AThread->Connection->ReadBuffer(ptr, len);
> How can I know exactly the bytes that has been received in the socket ?
TCP is a byte stream. If you want to know the size of a particular buffer
within that stream, then you should be sending the buffer size before then
sending the buffer data. Indy is a blocking library. If you tell it to
read xxx number of bytes, then it waits until at least xxx number of bytes
are available before returning them.
> How can I know exactly the bytes that has been received in the socket ?
What you are asking for applies primarily to asynchronous sockets, not
blocking sockets. That is not the case with Indy. You tell it how much to
read, and it returns that much back to you, internally handling all of the
waiting and gathering of packet pieces for you.
If that does not work for your situation, then your only option is to use
CurrentReadBuffer(), which returns a String of all available bytes. Or
alternatively call ReadFromStack() and then manually pull the available
bytes from the InputBuffer property.
> Is a method like ReceiveLength() exist with TidTcpServer?
No.
Gambit
Re: indy 9 and TidTcpServer
Author: fabrice
Date: Wed, 02 Aug 2006 13:28
Date: Wed, 02 Aug 2006 13:28
48 lines
2683 bytes
2683 bytes
ok thanks for the reply "Remy Lebeau (TeamB)" <no.spam@no.spam.com> a οΏ½crit dans le message de news: 44cfb7b2$1@newsgroups.borland.com... > > "fabrice" <f.marcantuoni@splin-rd.com> wrote in message > news:44cf20f5$1@newsgroups.borland.com... > >> Before to read using "AThread->Connection->Socket->Recv(ptr,len)" > > Do NOT call Recv() directly! Use the reading methods from > TIdTCPConnection > instead, such as ReadBuffer(): > > AThread->Connection->ReadBuffer(ptr, len); > >> How can I know exactly the bytes that has been received in the socket ? > > TCP is a byte stream. If you want to know the size of a particular buffer > within that stream, then you should be sending the buffer size before then > sending the buffer data. Indy is a blocking library. If you tell it to > read xxx number of bytes, then it waits until at least xxx number of bytes > are available before returning them. > >> How can I know exactly the bytes that has been received in the socket ? > > What you are asking for applies primarily to asynchronous sockets, not > blocking sockets. That is not the case with Indy. You tell it how much > to > read, and it returns that much back to you, internally handling all of the > waiting and gathering of packet pieces for you. > > If that does not work for your situation, then your only option is to use > CurrentReadBuffer(), which returns a String of all available bytes. Or > alternatively call ReadFromStack() and then manually pull the available > bytes from the InputBuffer property. > >> Is a method like ReceiveLength() exist with TidTcpServer? > > No. > > > 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