Writing strings to file!! TStreamFile

From: Carlos (carlos_at_aol.com)
Date: 10/27/03


Date: 27 Oct 2003 07:02:23 -0700


Hi,

I need to create a file image from data being receiving from a socket connection. The data are basicaly strings, with some special characteres used as control tags (ASCII < 31)

What I did (this is a simple example to understand what I need):

var img:TStreamFile; <-- at the begining the code
.
.
.
  img := TStreamFile('img.tmp',fmCreate); <-- create stream file
.
.
.
procedure TForm1.Socket1Read(Sender: TObject; Socket: TCustomWinSocket);
var tmp:string;
begin
    
     tmp := Clt.Socket.ReceiveText; <- receiving as text
     
     img.WriteBuffer(tmp,length(tmp)); // write data to the file

     if Pos(EOT,tmp) then
     begin
          img.Free; // close the file
          exit;
     end;

end;

I am using the basic TSocket from D5. The problem is because the file gets wrong, not the image. It writes other binary data that doesn't correspond from the receiving data.

I did such code using BlockWrite with the same problem.

I would appreciate any help!! :(

Thank you all!



Relevant Pages

  • Re: Master/worker design
    ... > 1) I am trying to multiplex text and binary data on the same socket. ... will tell you the number of elements in any string. ... before you can measure and transmit it. ...
    (comp.lang.tcl)
  • Re: Desperately need help in Tcl socket and fileevent puzzle...
    ... > 1) connect to a socket ... > 2) setup a fileevent handler to read binary data coming from this ... fconfigure $channel -translation binary ... You'll want to also make the $binFile channel a binary channel. ...
    (comp.lang.tcl)
  • Re: Tk event loop
    ... stuffed into a block of binary data, sent over a socket/pipe to wish, ... I want asynchronousity within one application. ... X communicates with an app via a socket. ... what package should I include in my 'package require' command? ...
    (comp.lang.tcl)
  • RE: System.Byte() array convert to string... HOW???
    ... Because a socket is a fundamentally binary object. ... that the framework makes such a clear distinction between binary data ... framework, ...
    (microsoft.public.dotnet.general)
  • Re: perl module to write on a var
    ... I've been using a perl module that writes binary data on a file...now ... I'd rather save the data on a var kept in memory (I must not save the ... docs hint otherwise. ... The constructor hints that you can't, ...
    (comp.lang.perl.misc)