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 

TidTCPConnection read data delay

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





PostPosted: Tue Jan 17, 2006 5:51 am    Post subject: TidTCPConnection read data delay Reply with quote




I build a client/server program, use TIdTCPServer in Server and use
TIdTCPClient in Client, as fllowing:
--------------------------------------------------
Server: in on execute event, i write some codes
TIdTCPServer.OnExecute(AThread: ...)
var
I: Integer;
begin
I:= AThread.Connection.ReadInteger;
I:= 10;
AThread.Connection.WriteInteger(I);
I:= 20;
AThread.Connection.WriteInteger(I);
end;

Client: in a button's click event

OnButtonClick(Sender: TObject)
var
I: Integer;
begin
I:= 10;
TCPClient.WriteInteger(I);
I:= TCPClient.ReadInteger;

//the following line has some error
I:= TCPClient.ReadInteger;
end;
-------------------------------------------------------------
while my server app and client app run in the same computer, the line in
codes mark with red will run normal, and speed is fast. But while server app
and client app run in two computers, client app will delay(the line mark
with red in codes), please tell me how to solve this problem?


Back to top
Bob Gonder
Guest





PostPosted: Tue Jan 17, 2006 5:28 pm    Post subject: Re: TidTCPConnection read data delay Reply with quote



supaul wrote:

Quote:
while my server app and client app run in the same computer, the line in
codes mark with red will run normal, and speed is fast. But while server app
and client app run in two computers, client app will delay(the line mark
with red in codes), please tell me how to solve this problem?

(There are no colors in the newsgroup, better to mark the lines with
comments)

See my message from 5/4/2005
[email]50th71db9qmpnog2gldkeqvsfv112h3ano (AT) 4ax (DOT) com[/email]

Subject: Re: sendto to same destination more times after eachother
fails.?


TCP buffers data so the data-to-packetheader ratio is sane. When
sending a single integer, the packet is several times the size of the
data, quite wastefull, so by default, TCP holds onto the data for a
period of time, hoping more data will be sent.
If you don't want to wait for the timeout, you need to tell TCP not to
wait.

Look into this WinSock API command, and parameters..

setsockopt(ClientOutSocket,IPPROTO_TCP,TCP_NODELAY,(char*)&t,sizeof(t));




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue Jan 17, 2006 8:06 pm    Post subject: Re: TidTCPConnection read data delay Reply with quote




"supaul" <qzwusir (AT) 163 (DOT) com> wrote


Quote:
I build a client/server program, use TIdTCPServer in
Server and use TIdTCPClient in Client, as fllowing:

Which version of Indy you are using?

Quote:
//the following line has some error
I:= TCPClient.ReadInteger;

Please be more specific. What EXACTLY is happening?


Gambit



Back to top
supaul
Guest





PostPosted: Wed Jan 18, 2006 3:57 am    Post subject: Re: TidTCPConnection read data delay Reply with quote

Thanks, it is correct!
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid>
??????:ap9qs1pu7b6mf7cn9v9gejknfau59l1nmv (AT) 4ax (DOT) com...
Quote:
supaul wrote:

while my server app and client app run in the same computer, the line in
codes mark with red will run normal, and speed is fast. But while server
app
and client app run in two computers, client app will delay(the line mark
with red in codes), please tell me how to solve this problem?

(There are no colors in the newsgroup, better to mark the lines with
comments)

See my message from 5/4/2005
[email]50th71db9qmpnog2gldkeqvsfv112h3ano (AT) 4ax (DOT) com[/email]

Subject: Re: sendto to same destination more times after eachother
fails.?


TCP buffers data so the data-to-packetheader ratio is sane. When
sending a single integer, the packet is several times the size of the
data, quite wastefull, so by default, TCP holds onto the data for a
period of time, hoping more data will be sent.
If you don't want to wait for the timeout, you need to tell TCP not to
wait.

Look into this WinSock API command, and parameters..

setsockopt(ClientOutSocket,IPPROTO_TCP,TCP_NODELAY,(char*)&t,sizeof(t));






Back to top
supaul
Guest





PostPosted: Wed Jan 18, 2006 3:58 am    Post subject: Re: TidTCPConnection read data delay Reply with quote

when tcpclient read from server, it always delay 200ms, now it is correct, I
set then socket.UseNagle to false!
Thanks:)

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> 写入消息新闻
:43cd4e31$1 (AT) newsgroups (DOT) borland.com...
Quote:

"supaul" <qzwusir (AT) 163 (DOT) com> wrote in message
news:43cc863b (AT) newsgroups (DOT) borland.com...

I build a client/server program, use TIdTCPServer in
Server and use TIdTCPClient in Client, as fllowing:

Which version of Indy you are using?

//the following line has some error
I:= TCPClient.ReadInteger;

Please be more specific. What EXACTLY is happening?


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.