Capturing Data from ICS TWSocket Into a File?

Currently i do like this and it gives me an out of memory exception after like few hours. It was supposed to capture a day's data and then save it into a file.

procedure TfmMain.MySocketDataAvailable(Sender: TObject; Error: Word);
  SocketData: String;

  SocketData := MySocket.ReceiveStr;
 // process SocketData here, code's been taken out
    FCapturedData := FCapturedData + SocketData;
    on E: Exception do
      lbException.Caption := 'Exception on capturing data: ' + E.Message;

Maybe i should save the captured string into a file and then append like every hour or after the string size reach a predefine limit. But i think this will slow down the program as the captured string need to be appended to file for several times or more?

Any better solution?
Who is Participating?
I suspect a single string is too small to hold all of your data, so you're going to have to use more than one; a TStringList seems to me to be the best alternative. For playback purposes, you can just ignore the string boundaries.
Instead of concatenating SocketData to a single string (FCapturedData), why not add it as a new line to a hidden TMemo or TStringList which you occasionally write out to a disk file?
cooleAuthor Commented:
Because i would like the data to be in it's original format so that i can playback the file with hyper terminal. Memo or StringList will store in a delimited format right unless i concatenate them into a string again?
I believe I earned these points
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.