Delphi Indy tcp server

Posted on 2014-03-21
Last Modified: 2014-03-24

I try to create an application
that takes all  data from a printout and save to a uniqe filename (or insert into a database)

it seems to work  as long as I don't try to print two documents at the same time.
How can I solve this...

My code::

    sl : TstringList;
    MyDataStr : string;


procedure TfForm1.IdTCPServer1Connect(AContext: TIdContext);
   sl :=TstringList.Create;
  MyDataStr:= '';


procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
  sl.Text:= MyDataStr;
  sl.SaveToFile(MyDir+ \GetUniqeFileName);
Question by:pucko73
1 Comment
LVL 26

Accepted Solution

Sinisa Vuk earned 500 total points
ID: 39946684
You need create string list by context (create separate string list by each client connected)

procedure TfForm1.IdTCPServer1Connect(AContext: TIdContext);
   AContext.Data := TstringList.Create;

procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
  CliContext: TStringList;
    CliContext.SaveToFile(MyDir+ \GetUniqeFileName); 
    AContext.Data := nil;

procedure TfForm1.IdTCPServer1Execute(AContext: TIdContext);
    if not AContext.Connection.IOHandler.InputBufferIsEmpty then bytes here and store in string list as 

Open in new window

sl  and MyDataStr is no longer needed ...

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi with SQL Natvie Client 15 86
Using idhttp to login to instagram 2 76
Delphi Form ownership 4 73
RESTRequest Parameter 4 12
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now