 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
supaul Guest
|
Posted: Tue Jan 17, 2006 5:51 am Post subject: TidTCPConnection read data delay |
|
|
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
|
Posted: Tue Jan 17, 2006 5:28 pm Post subject: Re: TidTCPConnection read data delay |
|
|
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
|
Posted: Tue Jan 17, 2006 8:06 pm Post subject: Re: TidTCPConnection read data delay |
|
|
"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
|
Posted: Wed Jan 18, 2006 3:57 am Post subject: Re: TidTCPConnection read data delay |
|
|
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
|
Posted: Wed Jan 18, 2006 3:58 am Post subject: Re: TidTCPConnection read data delay |
|
|
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 |
|
 |
|
|
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
|
|