Hello Larini,

> I'm getting unstable times, from 70 ms to 3 seconds.

This can happen. It is depending the traffic on the network. If very
heavy on a large network it _can_ take a while.

> while gWait do
> begin
> application.ProcessMessages;
> sleep(1);
> end;

This is not needed, you only waste CPU here. Use ClientDataAvailable to
send the next, not for flagging a loop !

---
Rgds, Wilfried [TeamICS]
http://www.overbyte.be/eng/overbyte/teamics.html
http://www.mestdagh.biz

Wednesday, November 9, 2005, 21:26, Larini wrote:

> Hi, here is my simple app, one client and one server. The mission: send a
> message from client to server and wait for replay.
> I'm getting unstable times, from 70 ms to 3 seconds. My question is: this is
> normal? What kind of client-server configuration I must have to get more
> stable results (like 200 ms most of time)?


> Client:
> procedure TForm2.clientSessionConnected(Sender: TObject; ErrCode: Word);
> var a:Integer;
> begin
> for a:=0 to 500 do
> begin
> LastTick:=Gettickcount;
> Client.SendLine('************************************************* msg to
> server *****************************************');
> gWait:=true;
> while gWait do
> begin
> application.ProcessMessages;
> sleep(1);
> end;
> end;
> end;

> procedure TForm2.clientDataAvailable(Sender: TObject; ErrCode: Word);
> var s:String;
> begin
> if ErrCode<>0 then
> exit;
> s:=Client.ReceiveStr;
> memo1.lines.add(Inttostr(Gettickcount-LastTick)+' - '+ trim(s));
> gWait:=false;
> end;

> Server:
> procedure TForm1.CliSocketDataAvailable(Sender: TObject; ErrCode: Word);
> var s:String;
> begin
> if ErrCode<>0 then
> exit;
> s:=(sender as TWSocket).ReceiveStr;
> memo1.Lines.Add(trim(s));
> (sender as TWSocket).SendLine(trim(s));
> end;


> Result:
> 109 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 47 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 4343 - ************************************************* msg to server
> *****************************************
> 63 - ************************************************* msg to server
> *****************************************
> 47 - ************************************************* msg to server
> *****************************************
> 63 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 62 - ************************************************* msg to server
> *****************************************
> 219 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 63 - ************************************************* msg to server
> *****************************************
> 47 - ************************************************* msg to server
> *****************************************
> 63 - ************************************************* msg to server
> *****************************************
> 296 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 78 - ************************************************* msg to server
> *****************************************
> 781 - ************************************************* msg to server
> *****************************************
> 329 - ************************************************* msg to server
> *****************************************
> 188 - ************************************************* msg to server
> *****************************************
> 157 - ************************************************* msg to server
> *****************************************
> 141 - ************************************************* msg to server
> *****************************************
> 907 - ************************************************* msg to server
> *****************************************
> 235 - ************************************************* msg to server
> *****************************************


> ________________________________________________
> This mail was sent by
> Webmail 2.5


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to