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

  • SEARCH
  • Home
  • 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 8032773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:29:25+00:00 2026-06-05T01:29:25+00:00

Hi I have try to read Stream from the server with this code void

  • 0

Hi I have try to read Stream from the server with this code

void __fastcall TForm1::Edit1KeyPress(TObject *Sender, wchar_t &Key)
{
   //TMemoryStream *TMS = new TMemoryStream;
   TStringStream *TSS = new TStringStream;
   AnsiString A,B;
   TStream *TS;
   INT64 Len;
   try
   {
       if (Key == VK_RETURN)
       {
          Beep(0,0);
          if(Edit1->Text == "mystream")
           {
               TCPClient1->IOHandler->WriteLn("mystream");
               Len = StrToInt(TCPClient1->IOHandler->ReadLn());
               TCPClient1->IOHandler->ReadStream(TS,Len,false);
               TSS->CopyFrom(TS,0);
               RichEdit1->Lines->Text = TSS->DataString;
               Edit1->Clear();
           }
       else
           {
              TCPClient1->IOHandler->WriteLn(Edit1->Text);
              A = TCPClient1->IOHandler->ReadLn();
              RichEdit1->Lines->Add(A);
              Edit1->Clear();
           }
       }
   }
   __finally
   {
       TSS->Free();
   }

}

and every times client try to read stream from the server, compiler says.

First chance exception at $75D89617. Exception class EAccessViolation with message 'Access violation at address 500682B3 in module 'rtl140.bpl'. Read of address 00000018'. Process Project1.exe (6056)

How to handle this?

  • 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-05T01:29:27+00:00Added an answer on June 5, 2026 at 1:29 am

    You are not instantiating your TStream object before calling ReadStream(). Your TS variable is completely uninitialized. ReadStream() does not create the TStream object for you, only writes to it, so you have to create the TStream yourself beforehand.

    Given the code you have shown, you can replace the TStream completely by using the ReadString() method instead:

    void __fastcall TForm1::Edit1KeyPress(TObject *Sender, wchar_t &Key) 
    { 
        if (Key == VK_RETURN) 
        { 
            Beep(0,0); 
            if (Edit1->Text == "mystream") 
            { 
                TCPClient1->IOHandler->WriteLn("mystream"); 
                int Len = StrToInt(TCPClient1->IOHandler->ReadLn()); 
                RichEdit1->Lines->Text = TCPClient1->IOHandler->ReadString(Len); 
            } 
            else 
            { 
                TCPClient1->IOHandler->WriteLn(Edit1->Text); 
                String A = TCPClient1->IOHandler->ReadLn(); 
                RichEdit1->Lines->Add(A); 
            } 
            Edit1->Clear(); 
        } 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this: public form() { InitializeComponent(); init(); //read ini and try
I have used the code below to read rfid tag values. try { if
I have a try catch in my physical C# code that just skips this
I have a server link from where I need to read the pdf content.
I have the following code: http://pastebin.com/U9qYSmET When I try to telnet into my server
What I try to accomplish is to read from a stream directly into a
I have a stream from an icecast server downloading, and I can grab the
Hi I have been using the Buffered Reader to try to read a text
I have read a file with around 120k words so i try to do
I have set up WebDAv server on my Debian linux and this is working

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.