The recieveText function on the socket is probably expecting a null
terminated string. As a result, the variable "b" is holding a truncated
version of the file your are sending over your socket.
Send a length variable before sending the whole file, and use the binary
read/write functions of your socket class (you probably dont need to use a
buffer string at all).
Wilfred.
-----Original Message-----
From: Matthew Comb [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 21 June 2000 09:53
To: Multiple recipients of list delphi
Subject: [DUG]: socket dummy!
Can anyone tell me anything blatently wrong with the following code, it
should send a file through a sockets connection and pop out the other end?
(Is there a better way to do it?) - I realise that I need to handle a lot
more things but just want to see I'm on the right track first. A file pops
out the other end the right size but it has been corrupted.
code which sends <<<<<<<<<<<
f:=tfilestream.create('c:\conference_title.bmp',fmOpenReadwrite);
try
setlength(result1, f.Size);
if f.Size > 0 then
f.Read(result1[1], f.size);
finally
f.free;
end;
socketfile.Socket.Sendtext(result1);
code which reads <<<<<<<<<<<<<<<<<
b:=socket.receivetext;
aa.Write(b,length(b));
Any help much appreciated...
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz