[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

I need a TCPDemo for Indy 10

Posted on 2006-04-04
14
Medium Priority
?
2,876 Views
Last Modified: 2012-08-14
I need a TCPDemo like in Indy 9 for Indy 10 or tell me where can I find it.
0
Comment
Question by:diandr
  • 7
  • 5
  • 2
14 Comments
 
LVL 2

Accepted Solution

by:
Mainiacfreakus earned 1500 total points
ID: 16375270
I can write you a simple one if the ones below are not suffiecient.

http://www.indyproject.org/Sockets/Demos/index.en.iwp
http://www.atozed.com/indy/Demos/

Mainiacfreakus
0
 

Author Comment

by:diandr
ID: 16376170
Thakns for the anwser
On these two links I already have been.
But there is a example TCPClient with SSL.
I need an example for server and client without SSL.
0
 
LVL 2

Expert Comment

by:Mainiacfreakus
ID: 16379163
Sure,

Will do it tonight...

Mainiacfreakus
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:diandr
ID: 16379732
Thanks

Also I should mention that in the execute event of Tidtcpserver I use adressing to components from the form like memo,edits and on a command (fom the client) I make there calculations(which can take 2-3 seconds). Also there I make adressing to TTable. Can you put those components too and make a simple add field(ttable) and a memo adressing on a specific command.
0
 

Author Comment

by:diandr
ID: 16407855
Anything new Mainiacfreakus?

diandr
0
 
LVL 2

Expert Comment

by:Mainiacfreakus
ID: 16408010
Sorry, been a bit busy... :(

Here you go:
Client:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdCustomTransparentProxy, IdConnectThroughHttpProxy,
  IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack, IdBaseComponent,
  IdComponent, IdTCPConnection, IdTCPClient, IdStack, Mask, ExtCtrls;

type
  TForm1 = class(TForm)
    IdTCPClient1: TIdTCPClient;
    IdIOHandlerStack1: TIdIOHandlerStack;
    Button1: TButton;
    Label1: TLabel;
    MaskEdit1: TMaskEdit;
    Button2: TButton;
    Edit1: TEdit;
    Timer1: TTimer;
    Button3: TButton;
    Edit2: TEdit;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure IdTCPClient1Connected(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
  public
    procedure UpdateForm();
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure Tform1.UpdateForm();
begin
  Case idtcpclient1.Connected of
    True : Begin
      Button1.Caption := 'Disconnect';
    End;
    False : Begin
      Button1.Caption := 'Connect';
    End;
  End;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Case idtcpclient1.Connected of
    True : idtcpclient1.Disconnect;  { SendMsg('DXDKill');}
    False : Begin
//      AddMemo('Attempting to Contact : '+Tcp.Host);
      try
        idtcpclient1.Connect;
      except
        On E:EIdSocketError do Begin
//          AddMemo('Server response timeout!');
//          AddMemo('Server is unavailable or Host Address and Port are incorrect.');
        End;
      End;
    End;
  End;
end;

procedure TForm1.IdTCPClient1Connected(Sender: TObject);
begin
  ShowMessage('Connected to Server');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  If idtcpclient1.Connected then idtcpclient1.IOHandler.WriteLn('addtomemo:'+edit1.Text);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  If idtcpclient1.Connected then Begin
    IdTCPClient1.CheckForGracefulDisconnect(True);
    If not IdTCPClient1.IOHandler.InputBufferIsEmpty then ShowMessage(IdTCPClient1.IOHandler.ReadLn);
  End;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  If idtcpclient1.Connected then idTCPClient1.IOHandler.WriteLn('calculation!');
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  If idtcpclient1.Connected then idTCPClient1.IOHandler.WriteLn('tablefield:');
end;

end.

-------------------------------------------------------------------------------------------

object Form1: TForm1
  Left = 203
  Top = 168
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 8
    Top = 8
    Width = 22
    Height = 13
    Caption = 'Host'
  end
  object Button1: TButton
    Left = 152
    Top = 16
    Width = 75
    Height = 25
    Caption = 'Connect'
    TabOrder = 0
    OnClick = Button1Click
  end
  object MaskEdit1: TMaskEdit
    Left = 8
    Top = 24
    Width = 132
    Height = 22
    EditMask = '###.###.###.###;1; '
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'Times New Roman'
    Font.Style = []
    MaxLength = 15
    ParentFont = False
    TabOrder = 1
    Text = '   .   .   .   '
  end
  object Button2: TButton
    Left = 152
    Top = 56
    Width = 145
    Height = 25
    Caption = 'Add to Memo on Server'
    TabOrder = 2
    OnClick = Button2Click
  end
  object Edit1: TEdit
    Left = 8
    Top = 56
    Width = 121
    Height = 21
    TabOrder = 3
    Text = 'Edit1'
  end
  object Button3: TButton
    Left = 8
    Top = 96
    Width = 185
    Height = 25
    Caption = 'Calculation'
    TabOrder = 4
    OnClick = Button3Click
  end
  object Edit2: TEdit
    Left = 8
    Top = 136
    Width = 121
    Height = 21
    TabOrder = 5
    Text = 'Edit2'
  end
  object Button4: TButton
    Left = 152
    Top = 136
    Width = 145
    Height = 25
    Caption = 'Add Field'
    TabOrder = 6
    OnClick = Button4Click
  end
  object IdTCPClient1: TIdTCPClient
    ConnectTimeout = 0
    Host = '127.0.0.1'
    IPVersion = Id_IPv4
    OnConnected = IdTCPClient1Connected
    Port = 6667
    ReadTimeout = -1
    Left = 232
    Top = 16
  end
  object IdIOHandlerStack1: TIdIOHandlerStack
    MaxLineAction = maException
    Port = 0
    DefaultPort = 0
    Left = 264
    Top = 16
  end
  object Timer1: TTimer
    Interval = 500
    OnTimer = Timer1Timer
    Left = 304
    Top = 16
  end
end

____________________________________________________________________
Server:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdServerIOHandler, IdServerIOHandlerSocket,
  IdServerIOHandlerStack, IdScheduler, IdSchedulerOfThread,
  IdSchedulerOfThreadDefault, IdBaseComponent, IdComponent,
  IdCustomTCPServer, IdTCPServer, StdCtrls, IdContext, DB, DBTables;

type
  TForm1 = class(TForm)
    IdTCPServer1: TIdTCPServer;
    IdSchedulerOfThreadDefault1: TIdSchedulerOfThreadDefault;
    IdServerIOHandlerStack1: TIdServerIOHandlerStack;
    cmdSServer: TButton;
    memMain: TMemo;
    Table1: TTable;
    procedure cmdSServerClick(Sender: TObject);
    procedure IdTCPServer1Execute(AContext: TIdContext);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    Calclist: TThreadlist;
  public
    procedure UpdateFrm();
    procedure SSServer(Start : Boolean);
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.cmdSServerClick(Sender: TObject);
begin
  Case cmdSServer.Tag of
    1 : SSServer(True);
    2 : SSServer(False);
  End;
end;

procedure TForm1.SSServer(Start : Boolean);
begin
  If (Start) and not(IdTCPServer1.Active) then Begin
    IdTCPServer1.Active := True;
//    LSUsers(True);
  End
  Else If not(Start) and (IdTCPServer1.Active) then Begin
    IdTCPServer1.Active := False;
//    LSUsers(False);
  End;
  UpdateFrm;
end;

procedure TForm1.UpdateFrm();
begin
//  Exit;  (* Disable VCL Controls *)
  With cmdSServer do Begin
    If IdTCPServer1.Active then Begin
      Tag := 2;
      Caption := 'Stop Server';
    End
    Else Begin
      Tag := 1;
      Caption := 'Start Server';
    End;
  End;
end;

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var MsgClient : String;
    CalcThread : TCalculator;
    NewField : TField;
begin (* Execute Client Code *)
  If AContext.Connection.IOHandler.InputBufferIsEmpty then Exit;
  MsgClient := AContext.Connection.IOHandler.ReadLn;
  try
    If MsgClient = '' then Exit;
    If Copy(Uppercase(MsgClient),1,10) = 'ADDTOMEMO:' then memMain.Lines.Add(Copy(MsgClient,11,Length(MsgClient)-10));
    If Copy(Uppercase(MsgClient),1,12) = 'CALCULATION!' then Begin
      calcthread := TCalculator.Create(False);  ***
      calcthread.ClientContext := Acontext;
      Calclist.Add(calcthread);
    End;
    If Copy(Uppercase(Msgclient),1,11) = 'TABLEFIELD:' then Begin
      Newfield := TField.Create(Table1);
      Newfield.FieldName := Copy(MsgClient,12,Length(MsgClient)-11);
      Table1.Fields.Add(Newfield);
    End;
  except
    on E:Exception do Begin
      AContext.Connection.Disconnect;
    End;
  End;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  CalcList := TThreadList.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Calclist.Free;
end;

end.

--------------------------------------------------------------------------------------

object Form1: TForm1
  Left = 192
  Top = 110
  Width = 696
  Height = 480
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  PixelsPerInch = 96
  TextHeight = 13
  object cmdSServer: TButton
    Tag = 1
    Left = 168
    Top = 208
    Width = 75
    Height = 25
    Caption = 'Start Server'
    TabOrder = 0
    OnClick = cmdSServerClick
  end
  object memMain: TMemo
    Left = 0
    Top = 0
    Width = 241
    Height = 193
    TabOrder = 1
  end
  object IdTCPServer1: TIdTCPServer
    Bindings = <>
    DefaultPort = 6667
    IOHandler = IdServerIOHandlerStack1
    Scheduler = IdSchedulerOfThreadDefault1
    OnExecute = IdTCPServer1Execute
    Left = 312
    Top = 64
  end
  object IdSchedulerOfThreadDefault1: TIdSchedulerOfThreadDefault
    MaxThreads = 0
    Left = 352
    Top = 64
  end
  object IdServerIOHandlerStack1: TIdServerIOHandlerStack
    Left = 272
    Top = 64
  end
  object Table1: TTable
    Left = 272
    Top = 96
  end
end

------------------------------------------------------------------------------------------

unit Unit2;

interface

uses
  Classes, idContext, sysutils;

type
  TCalculator = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute(); override;
  public
    ClientContext: TIdContext;
  end;

implementation

{ Calculator }

procedure TCalculator.Execute;
begin
  Sleep(4000); { @@@ - remove the sleep and add your calculations..
   (remember that if you use VCL controls you should define a new procedure in this thread and use synchronize to call that procedure wherein you use the VCL controls.)  }
  ClientContext.Connection.IOHandler.WriteLn('Calculation complete');
  Self.Terminate;
end;

end.

*** I have used a thread creation to make sure that the server continues to respond to client requests while the calculations are underway...  Add your calculations in at the @@@.

Hope this is all you wanted...
Have tested it on XP, however it has some bugs that i know about... needs some more code to fix these... (if you close the server while the client is connected to it).

Mainiacfreakus
0
 

Author Comment

by:diandr
ID: 16408568
I have a command which add a new record in Table. When I close the server everything is lost(all the records added). I found a solution by closing and then opening the table directly in the Onexecute method. Is there another solution?

diandr
0
 

Author Comment

by:diandr
ID: 16408581
I haven't tryed your source yet, but I also have problems like:
1.Some clients can't connect to the server(the connection I made exactly as you)
2.Some clients lose the connection.
What can cause these problems?

Thanks
diandr
0
 

Author Comment

by:diandr
ID: 16411893
I tried your client and server. The server is taking 97-99% from the CPU. I debugged and see that the following line:
  If AContext.Connection.IOHandler.InputBufferIsEmpty then Exit;
is keep called.

diandr
0
 
LVL 2

Expert Comment

by:Mainiacfreakus
ID: 16412472
Hi diandr

The reason for that line being continuously called is so that the server checks to see if there is a message waiting from the client. If this line was not called then the server would never repond to a client's message. And, yes, I know the server appears to be heavy on resources, however if you run another program the server threads will give way...

I don't know why you would be experiencing connection problems, maybe check your firewalls and other network protection programs to see if they aren't blocking the ports you are trying to use. (Maybe also check that your server and client are configured to the same port. There is another way to do this but normally only works if your client and server are on two different machines. - You can bind the server to the port)

Mainiacfreakus

(Sorry about time-delay in replies... I am currently away from my normal home.)
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 16413638
here's an example I wrote for Delphi 10
my demo allows you to send a file when you send a "FILE" command
You can change it to add other commands easily


unit Unit1;

interface
{
    Loki's Demo File sender/receiver - using Indy 10
    January 2006
    David Hooper (lokiwashere@yahoo.co.nz)
    All bugs reserved
}

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls, FileCtrl, IdAntiFreezeBase, IdAntiFreeze,
  IdTCPConnection, IdTCPClient, IdBaseComponent, IdComponent, IdTCPServer,
  IdContext, IDStreamVCL;

type
  TForm1 = class(TForm)
    IdTCPServer1: TIdTCPServer;
    IdTCPClient1: TIdTCPClient;
    IdAntiFreeze1: TIdAntiFreeze;
    gbServer: TGroupBox;
    rbServer: TRadioButton;
    rbClient: TRadioButton;
    bbStartServer: TBitBtn;
    bbStopServer: TBitBtn;
    mServerLog: TMemo;
    gbClient: TGroupBox;
    bbConnectClient: TBitBtn;
    bbDisconnectClient: TBitBtn;
    mClientLog: TMemo;
    bbSendFile: TBitBtn;
    OpenDialog1: TOpenDialog;
    ProgressBar1: TProgressBar;
    procedure bbStartServerClick(Sender: TObject);
    procedure rbServer_Or_Client_Click(Sender: TObject);
    procedure bbStopServerClick(Sender: TObject);
    procedure bbConnectClientClick(Sender: TObject);
    procedure bbDisconnectClientClick(Sender: TObject);
    procedure IdTCPServer1Status(ASender: TObject;
      const AStatus: TIdStatus; const AStatusText: String);
    procedure IdTCPClient1Status(ASender: TObject;
      const AStatus: TIdStatus; const AStatusText: String);
    procedure IdTCPServer1AfterBind(Sender: TObject);
    procedure IdTCPServer1Connect(AContext: TIdContext);
    procedure IdTCPServer1Disconnect(AContext: TIdContext);
    procedure bbSendFileClick(Sender: TObject);
    procedure IdTCPClient1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
      AWorkCountMax: Integer);
    procedure IdTCPClient1Work(ASender: TObject; AWorkMode: TWorkMode;
      AWorkCount: Integer);
    procedure IdTCPClient1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
    procedure IdTCPServer1Execute(AContext: TIdContext);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

IMPLEMENTATION

{$R *.DFM}

procedure TForm1.rbServer_Or_Client_Click(Sender: TObject);
    begin
// disconnect all
        IdTCPServer1.Active := False;
        if IdTCPClient1.Connected then
          IdTCPClient1.IOHandler.WriteLn('QUIT'); // send command "QUIT"
        gbServer.Enabled := rbServer.Checked;
        gbClient.Enabled := rbClient.Checked;
    end;

procedure TForm1.bbStartServerClick(Sender: TObject);
    begin
        IdTCPServer1.Active := True;
    end;

procedure TForm1.bbStopServerClick(Sender: TObject);
    begin
        IdTCPServer1.Active := False;
    end;

procedure TForm1.bbConnectClientClick(Sender: TObject);
    begin
        IdTCPClient1.Connect;
    end;

procedure TForm1.bbDisconnectClientClick(Sender: TObject);
    begin
        if IdTCPClient1.Connected then
          IdTCPClient1.IOHandler.WriteLn('QUIT'); // send command "QUIT"
// server will disconnect us
//        IdTCPClient1.Disconnect;
    end;

procedure TForm1.IdTCPServer1Status(ASender: TObject;
    const AStatus: TIdStatus; const AStatusText: String);
    begin
        mServerLog.Lines.Add(AStatusText);
    end;

procedure TForm1.IdTCPClient1Status(ASender: TObject;
    const AStatus: TIdStatus; const AStatusText: String);
    begin
        mClientLog.Lines.Add(AStatusText);
    end;

procedure TForm1.IdTCPServer1AfterBind(Sender: TObject);
    begin
        mServerLog.Lines.Add('Bound');
    end;

procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
    begin
        mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':Connected');
    end;

procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
    begin
        mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':Disconnected');
    end;

procedure TForm1.bbSendFileClick(Sender: TObject);
    var
        AStream: TIDStreamVCL;
    begin
        if OpenDialog1.Execute then
        begin
            AStream := TIDStreamVCL.Create(TFileStream.Create(OpenDialog1.Filename, fmOpenRead + fmShareDenyNone), True);
            try
                IdTCPClient1.IOHandler.WriteLn('FILE'); // send command "FILE"
                IdTCPClient1.IOHandler.WriteLn(ExtractFilename(OpenDialog1.Filename)); // send file name
                IdTCPClient1.IOHandler.WriteLn(IntToStr(AStream.VCLStream.Size)); // send file size
                mClientLog.Lines.Add('Sending file "' + ExtractFilename(OpenDialog1.Filename) + '"');
                ProgressBar1.Visible := True;
                IdTCPClient1.IOHandler.Write(AStream);
                mClientLog.Lines.Add('Sent file "' + ExtractFilename(OpenDialog1.Filename) + '"');
            finally
                FreeAndNil(AStream);
                ProgressBar1.Visible := False;
            end;
        end;
    end;

procedure TForm1.IdTCPClient1WorkBegin(ASender: TObject; AWorkMode: TWorkMode; AWorkCountMax: Integer);
    begin
        ProgressBar1.Max := AWorkCountMax;
        ProgressBar1.Position := 0;
    end;

procedure TForm1.IdTCPClient1Work(ASender: TObject; AWorkMode: TWorkMode; AWorkCount: Integer);
    begin
        if ProgressBar1.Visible then
          ProgressBar1.StepBy(AWorkCount);
    end;

procedure TForm1.IdTCPClient1WorkEnd(ASender: TObject; AWorkMode: TWorkMode);
    begin
        ProgressBar1.Position := 100;
        ProgressBar1.Visible := False;
    end;

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
    var
        s: string;
        AStream: TIDStreamVCL;
        Filename: string;
        FileSize: int64;
    begin
        while AContext.Connection.Connected do
        begin
            s := AContext.Connection.IOHandler.ReadLn;
            if S = 'FILE' then
            begin
                Filename := AContext.Connection.IOHandler.ReadLn; // get filename
                FileSize := StrToInt(AContext.Connection.IOHandler.ReadLn); // get filesize
                ForceDirectories(ExtractFilePath(Paramstr(0)) + 'In');
                AStream := TIDStreamVCL.Create(
                  TFileStream.Create(ExtractFilePath(Paramstr(0)) + 'In\' + Filename, fmCreate), True);
                try
                    mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':Receiving file "' + Filename + '" ' + IntToStr(Filesize) + ' bytes');
                    AContext.Connection.IOHandler.ReadStream(AStream, Filesize, False);
                    mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':Received file "' + Filename + '"');
                finally
                    FreeAndNil(AStream);
                end;
            end
            else if S = 'QUIT' then
            begin
                mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':QUIT');
                AContext.Connection.Disconnect;
            end
            else
            begin
                mServerLog.Lines.Add(AContext.Connection.Socket.Binding.PeerIP + ':UNKNOWN COMMAND: ' + S);
                AContext.Connection.Disconnect;
            end;
        end;
    end;

end.


************************ FORM FOLLOWS***********************
************************ FORM FOLLOWS***********************
object Form1: TForm1
  Left = 274
  Top = 107
  Width = 629
  Height = 570
  Caption =
    'Loki'#39's demo file sender - run this app twice. once for server,on' +
    'ce or more for client(s)'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object gbServer: TGroupBox
    Left = 8
    Top = 32
    Width = 609
    Height = 241
    TabOrder = 0
    object bbStartServer: TBitBtn
      Left = 8
      Top = 16
      Width = 89
      Height = 25
      Caption = 'Start Server'
      TabOrder = 0
      OnClick = bbStartServerClick
    end
    object bbStopServer: TBitBtn
      Left = 104
      Top = 16
      Width = 89
      Height = 25
      Caption = 'Stop Server'
      TabOrder = 1
      OnClick = bbStopServerClick
    end
    object mServerLog: TMemo
      Left = 8
      Top = 48
      Width = 593
      Height = 185
      TabOrder = 2
    end
  end
  object rbServer: TRadioButton
    Left = 8
    Top = 16
    Width = 65
    Height = 17
    Caption = 'Server'
    Checked = True
    TabOrder = 1
    TabStop = True
    OnClick = rbServer_Or_Client_Click
  end
  object rbClient: TRadioButton
    Left = 8
    Top = 280
    Width = 57
    Height = 17
    Caption = 'Client'
    TabOrder = 2
    OnClick = rbServer_Or_Client_Click
  end
  object gbClient: TGroupBox
    Left = 8
    Top = 296
    Width = 609
    Height = 241
    Enabled = False
    TabOrder = 3
    object bbConnectClient: TBitBtn
      Left = 8
      Top = 16
      Width = 89
      Height = 25
      Caption = 'Connect'
      TabOrder = 0
      OnClick = bbConnectClientClick
    end
    object bbDisconnectClient: TBitBtn
      Left = 104
      Top = 16
      Width = 89
      Height = 25
      Caption = 'Disconnect'
      TabOrder = 1
      OnClick = bbDisconnectClientClick
    end
    object mClientLog: TMemo
      Left = 8
      Top = 48
      Width = 593
      Height = 161
      TabOrder = 2
    end
    object bbSendFile: TBitBtn
      Left = 208
      Top = 16
      Width = 89
      Height = 25
      Caption = 'Send File'
      TabOrder = 3
      OnClick = bbSendFileClick
    end
    object ProgressBar1: TProgressBar
      Left = 8
      Top = 216
      Width = 593
      Height = 16
      Min = 0
      Max = 100
      TabOrder = 4
    end
  end
  object IdTCPServer1: TIdTCPServer
    OnStatus = IdTCPServer1Status
    Bindings = <>
    DefaultPort = 9898
    OnAfterBind = IdTCPServer1AfterBind
    OnConnect = IdTCPServer1Connect
    OnExecute = IdTCPServer1Execute
    OnDisconnect = IdTCPServer1Disconnect
    Left = 72
    Top = 40
  end
  object IdTCPClient1: TIdTCPClient
    OnStatus = IdTCPClient1Status
    OnWork = IdTCPClient1Work
    OnWorkBegin = IdTCPClient1WorkBegin
    OnWorkEnd = IdTCPClient1WorkEnd
    ConnectTimeout = 0
    Host = '127.0.0.1'
    IPVersion = Id_IPv4
    Port = 9898
    ReadTimeout = 0
    Left = 104
    Top = 304
  end
  object IdAntiFreeze1: TIdAntiFreeze
    Left = 40
    Top = 304
  end
  object OpenDialog1: TOpenDialog
    Left = 40
    Top = 336
  end
end
0
 

Author Comment

by:diandr
ID: 16459506
Hi Mainiacfreakus,

The server don't give away and completely freeze the whole computer. The indy 9 demo actually have 0% from the cpu. For indy 10 there is no such solution?

diandr
0
 
LVL 17

Expert Comment

by:TheRealLoki
ID: 16465797
Does it really freeze teh whole pc? or just appear to freeze teh application?
If the latter, then just drop a TIdAntiFreeze on the form.
You could also try my Indy 10 example if all else fails :-)
0
 
LVL 2

Expert Comment

by:Mainiacfreakus
ID: 16484942
hi diandr

I don't know, however I don't think so...

The TIdSchedulerOfThreadDefault continually iterates though all clients; thus it appears that the cpu usage is 100%.
I will look into it for you on the weekend.

Mainiacfreakus
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 20 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question