Limit bandwidth of clients with TCPServer

Giganews Newsgroups
Subject: Limit bandwidth of clients with TCPServer
Posted by:  Bahtiyar KARANLIK (karanl…@boun.edu.tr)
Date: Mon, 27 Feb 2006

Hi all,

i am trying to limit the bandwidth of clients on server. i tried something
like below but client disconnects immediate with "Connection Closed
Gracefully" error.
is there something wrong with this code?

procedure TForm1.TCPServerConnect(AThread: TIdPeerThread);
var
  IOHandlerThrottle: TIdIOHandlerThrottle;
  IOHandlerSocket: TIdIOHandlerSocket;
begin
  IOHandlerSocket:=TIdIOHandlerSocket.Create(nil);
  IOHandlerThrottle:=TIdIOHandlerThrottle.Create(AThread.Connection);
  IOHandlerThrottle.ChainedHandler:=IOHandlerSocket;
  IOHandlerThrottle.BytesPerSec:=(50*1024);
  AThread.Connection.IOHandler:=IOHandlerSocket;
end;

thanks
Melih

Replies