jamesp0tter
Programmer
Hey guys,
like the title says, I can't save an incomming connection's data into a file, or at least not the correct data: I managed to TFileStream it but the data was all garbled, and seeing the file in an hex editor showed the contents of the saved data are very different from the actual one.
So, I ask, what can I do to resolve this?
I'm using the TSock component from Ward, might this be the problem?
I'm using an approach like this:
but it fires an exception
I tried a few other methods, like:
but also doesn't work, probably because saving a stream into a string isn't a very good idea (?).
If you guys have any ideas, I'd appreciate!
I preferably would like to keep the existing structure (firing the save-to-file stuff on the onRead event, which fires several times) rather than creating the socket and looping through incomming data, but if that's impossible to achieve I can try other methods
Thanks in advance!
jamesp0tter
p.s.: sorry for my (sometimes) bad english
like the title says, I can't save an incomming connection's data into a file, or at least not the correct data: I managed to TFileStream it but the data was all garbled, and seeing the file in an hex editor showed the contents of the saved data are very different from the actual one.
So, I ask, what can I do to resolve this?
I'm using the TSock component from Ward, might this be the problem?
I'm using an approach like this:
Code:
procedure TForm1.sock1Read(Sender: TObject; Count: Integer);
var fs:TFileStream;
begin
fs := TFileStream.Create('c:\temp\123.mp3',fmOpenReadWrite or fmCreate);
fs.Seek(0,soFromEnd);
(Sender as TSock).Stream.Read(fs,Count);
fs.Free;
end;
I tried a few other methods, like:
Code:
- var := (Sender as TSock).ReceiveCount(Count);
- fs.write(var,Count); // returns string of data
If you guys have any ideas, I'd appreciate!
I preferably would like to keep the existing structure (firing the save-to-file stuff on the onRead event, which fires several times) rather than creating the socket and looping through incomming data, but if that's impossible to achieve I can try other methods
Thanks in advance!
jamesp0tter
p.s.: sorry for my (sometimes) bad english