[EQ] how can i manage different connection speed ?

Giganews Newsgroups
Subject: [EQ] how can i manage different connection speed ?
Posted by:  Ahmadi (Ahmadisolness…@yahoo.com)
Date: Thu, 6 Mar 2008

Hi
i have some clients that are connected to my server.
the clients have different connection speed.some of them are using dialup
connection and other are using 1000mb LAN connection.
i have a main thread that use writebuffer command to send data for the
clients with a delay beetwen writing packets.the delay is a big problem for
me for the following reasons:
a)for the dialup clients is good, but for the LAN clients is bad, because
both have same speed over the network on the my server!
b)i can not remove delay! because writebuffer command can not keep very
amount of data and if i write many data without any delay on the socket.the
writebuffer command will be hang and never comeback(do not reach to next
command)! and all of my client will be suspend for some times!
here is my code (my writer thread in the server ) :

procedure TWriterThread.Execute;
var t:TBlock;
var s:TMemoryStream;
    i:integer;
    client:^TClient;
    fn:string;
begin
  repeat
    for i := 0 to ClientsCount - 1 do
    begin
      client:=@Clients[i];
      lastestWritingClient:=@Clients[i];
      if assigned(Client) then
      if not client^.deleted then
      begin
        if assigned(Client^.outputBuffer) then
        begin
          if not Client^.outputBuffer.isEmpty then
          begin
            t:=client^.outputBuffer.read;
            s:=TMemoryStream.Create;
            s.WriteBuffer(t,sizeof(t));    //**NOTE ** if i write all data
immediately, here i have hang !
            s.Position:=0;
            if client^.Thread.Connection.Connected then
              client^.Thread.Connection.IOHandler.Write(s,sizeof(t));
            s.Free;
          end;
        end;
      end;
      timeOut:=0;
    end;
    timeOut:=0;
    sleep(100);
  until false;
end;

Replies