I have used both compenets to send/receive text but now I'm trying to 
use it for sending files..
so I tried just simple to open the file binary, read it and send it to 
the Server

 TCommand = record
  ID : Integer;

  TFileBuf = record
    ID : Integer;
    bufSize : Integer;
    buf: array[0..1024] of Byte;

//send the file (client)
while ...
    BlockRead(f, FileBuf.buf, SizeOf(FileBuf.buf), FileBuf.bufSize);
    WSocket1.Send(@FileBuf, sizeof(FileBuf));

before sending the file, the server gets some information about it 
(size, name,  ...) - this works fine but if I try to send a file the 
server doesn't get any new record  from the client:

//ondata aviable...
  buf   : array[Word] of Byte;
  fData : TMemoryStream;

  Filebuf  : ^TFileBuf;
  Command : TCommand;
  FileInfo : TFileInfo;
  OldPos   : Integer;

 with sender as TWSocketClient do begin
   nRead := Receive(@buf, High(Buf)- Low(buf));
   OldPos := fdata.Position;
   fData.WriteBuffer(buf, nRead);
     fData.Position := OldPos;
     fdata.ReadBuffer(Command, SizeOf(Command));
     if Command.ID = 1 then begin
       fData.Position := OldPos;
       fdata.ReadBuffer(Filebuf, SizeOf(Filebuf));
       if CanWriteToFile then begin  //write data to file
         BlockWrite(f, Filebuf.buf, SizeOf(FileBuf.bufSize));
         currspeed:= currspeed + FileBuf.bufSize;
     end else
//... code for getting Fileinfo (works)

some strange thing I recognized was that the client was sending/reading 
data in full speed while I was debugging and executing my code step by 
step :(

has anybody an idea to solve this problem or another way to send a file 
except ftp or http (it shoud be recordbased)?

ps sorry for the huge code in my mail

thx Sela
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to