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 8868951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:22:24+00:00 2026-06-14T17:22:24+00:00

Was trying to write simple client and server recieveing/sending data through TMemoryStream . When

  • 0

Was trying to write simple client and server recieveing/sending data through TMemoryStream. When I push button in client btnTestClick it apperas an error
Access violation at address 005D5581 in module 'Client.exe'. Write of adress 00000000. What I do wrong?

Btw client server connection works okay I thin cuz IdTCPClient1Connected function is writing 'Client Connected!'.

Client code

procedure TForm1.btnTestClick(Sender: TObject);
var
  msRecInfo: TMemoryStream;
  arrOf: array of Integer; i:integer;
begin
  for i := 0 to 10 do
    arrOf[i]:=random(100);

  msRecInfo:= TMemoryStream.Create;

  try
    msRecInfo.Write(arrOf, SizeOf(arrOf));
    idTCPClient1.IOHandler.Write(msRecInfo);
  finally
     msRecInfo.Free;
  end;

end;

end

Server code

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
   msRecInfo: TMemoryStream;
  arrOf: array of Integer; i:integer;
begin
  msRecInfo:= TMemoryStream.Create;
  try
    AContext.Connection.IOHandler.ReadStream(msRecInfo, -1, False);

    msRecInfo.Position := 0;
    msRecInfo.Read(arrof, SizeOf(arrof));
  finally
    memo1.Lines.Add(IntToStr(arrOf[1]));
    msRecInfo.Free;
  end;
  //AContext.Connection.IOHandler.ReadStream(msRecInfo, SizeOf(arrOf));
  //msRecInfo.Read(arrOf, sizeOf(arrOf));
end;
  • 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-06-14T17:22:25+00:00Added an answer on June 14, 2026 at 5:22 pm

    You start writing into a dynamic array before you’ve allocated any elements for it. Dynamic arrays do not automatically grow like you might be used to from some other languages. You need to set their lengths first.

    If you haven’t set the length of a dynamic array, then it will just be a null pointer, which explains why you get an access violation at address 0.

    Change your btnTestClick method like so:

    var
      msRecInfo: TMemoryStream;
      arrOf: array of Integer;
      i: integer;
    begin
      SetLength(arrOf, 11);
      for i := 0 to 10 do
        arrOf[i] := Random(100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a very simple unix domain datagram client/server. Here is
i'm trying to write simple C openssl client and server. Here is client's code:
I'm trying to write simple client and server C programs, communicating with each other
I'm trying to write a simple server-client program, but I have a problem: I
I'm trying to write a simple WCF Server + gSOAP client proof-of-concept application using
i have a weird problem. I am trying to write simple Client - Server
I'm trying to write a simple client/server chat application in 2 languages - Java
i'm trying to write simple tcp\ip client-server. here is server code: internal class Program
I am trying to write a simple tcp client/server app that copies a file.
I'm trying to write simple client and server based on sockets in C. The

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.