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 

indy 9 and TidTcpServer

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





PostPosted: Tue Aug 01, 2006 2:37 pm    Post subject: indy 9 and TidTcpServer Reply with quote



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 !
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Aug 02, 2006 1:19 am    Post subject: Re: indy 9 and TidTcpServer Reply with quote



"fabrice" <f.marcantuoni@splin-rd.com> wrote in message
news:44cf20f5$1 (AT) newsgroups (DOT) borland.com...

Quote:
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);

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

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

Quote:
Is a method like ReceiveLength() exist with TidTcpServer?

No.


Gambit
Back to top
fabrice
Guest





PostPosted: Wed Aug 02, 2006 6:28 pm    Post subject: Re: indy 9 and TidTcpServer Reply with quote



ok

thanks for the reply


"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> a écrit dans le message de news:
44cfb7b2$1 (AT) newsgroups (DOT) borland.com...
Quote:

"fabrice" <f.marcantuoni@splin-rd.com> wrote in message
news:44cf20f5$1 (AT) newsgroups (DOT) 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

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.