Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7560871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:00:56+00:00 2026-05-30T13:00:56+00:00

I have Delphi lib which must return information read via socket. function GetBufferInfo(Address: PChar):

  • 0

I have Delphi lib which must return information read via socket.

function GetBufferInfo(Address: PChar): PChar; export; stdcall;
var
  BD: TBufferData;
begin
  BD := TBufferData.Create;
  Result := PChar(TBufferData.GetData);
  BD.Free;
end;

TBufferData class has a method ReadData which is being called when socket Read event fires. So it can be called several times until all info is read. The problem is how to wait while information is being read and don’t go out of GetBufferInfo method. I thought about threads but don’t know how exactly it can be done.

I created a small example which demonstrates the issue:

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils, Classes, Windows;

type
  TBufferData = class
  private
    FResult: string;
  public
    constructor Create;
    procedure ReadData(Sender: TObject; Buf: string; var Size: Integer);
    function GetData: string;
  end;

{ TBufferData }

var
  BD: TBufferData;
  s: string;
{ TBufferData }

constructor TBufferData.Create;
begin
  FResult := 'Some text received via socket';
end;

function TBufferData.GetData: string;
begin
  Result := FResult;
end;

procedure TBufferData.ReadData(Sender: TObject; Buf: string; var Size: Integer);
begin
  //info is being received from socket
  FResult := FResult + Buf;
end;

begin
  BD := TBufferData.Create;
  s := BD.GetData;
  Writeln(s);
  BD.Free;
  Readln;
end.

Thanks in advance
Yura

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:00:58+00:00Added an answer on May 30, 2026 at 1:00 pm

    Application.ProcessMessages for console would look like this. State flag will be set outside.

    while State <> stDone do begin
      ...
      ProcessMessages;
    end;
    
    procedure ProcessMessages;
    var
      Msg: TMsg;
    begin
      if PeekMessage(Msg,0,0,0,0) then begin
        GetMessage(Msg,0,0,0);
        DispatchMessage(Msg);
      end;
      Sleep(10);//sleep to avoid 25% processor decrease
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Delphi 2010 built DLL with two methods: function Foo1(a, b: Integer):PChar; export;
We have a .lib file with functionality that must be included in a Delphi
I have a Delphi DLL with a function defined as: function SubmitJobStringList(joblist: tStringList; var
I have a Delphi 5 executable that calls into a .NET assembly via the
I have a Delphi generic class that exposes a function with an argument of
I have a Delphi 7 dll that exports the following function: function StringTest(var StringOut
I have a Delphi 5 application in the application code calls a function in
I have a Delphi application database of which is in Oracle. Now there's a
we have a delphi application which contains a TXTextControl (v. 13.0). This application uses
I have a problem migrating from Delphi 2006 to Delphi 2009. A Project which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.