Re: [twsocket] TWsocket/TWsocketServer sending/receiving Files
Hello Sela, - Are you taken into account that nRead also can be 0 or -1 ? - You create a TStream in every OnDataAvailable. I think you need the TStream to put the file in right ? Then only create it one time. --- Rgds, Wilfried [TeamICS] http://www.overbyte.be/eng/overbyte/teamics.html http://www.mestdagh.biz Thursday, November 17, 2005, 21:50, Selahattin Erkoc wrote: > hi, > 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; > end; > TFileBuf = record > ID : Integer; > bufSize : Integer; > buf: array[0..1024] of Byte; > end; > //send the file (client) > while ... > BlockRead(f, FileBuf.buf, SizeOf(FileBuf.buf), FileBuf.bufSize); > FBuf.ID:=1; > WSocket1.Send(@FileBuf, sizeof(FileBuf)); > end; > 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... > var > buf : array[Word] of Byte; > fData : TMemoryStream; > Filebuf : ^TFileBuf; > Command : TCommand; > FileInfo : TFileInfo; > OldPos : Integer; > begin > fData:=TMemoryStream.Create; > GetMem(Filebuf,SizeOf(TFileBuf)); > with sender as TWSocketClient do begin >nRead := Receive(@buf, High(Buf)- Low(buf)); >OldPos := fdata.Position; >fData.WriteBuffer(buf, nRead); >try > 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; > Numwritten:=Numwritten+FileBuf.bufSize; >end; > 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
[twsocket] TWsocket/TWsocketServer sending/receiving Files
hi, 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; end; TFileBuf = record ID : Integer; bufSize : Integer; buf: array[0..1024] of Byte; end; //send the file (client) while ... BlockRead(f, FileBuf.buf, SizeOf(FileBuf.buf), FileBuf.bufSize); FBuf.ID:=1; WSocket1.Send(@FileBuf, sizeof(FileBuf)); end; 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... var buf : array[Word] of Byte; fData : TMemoryStream; Filebuf : ^TFileBuf; Command : TCommand; FileInfo : TFileInfo; OldPos : Integer; begin fData:=TMemoryStream.Create; GetMem(Filebuf,SizeOf(TFileBuf)); with sender as TWSocketClient do begin nRead := Receive(@buf, High(Buf)- Low(buf)); OldPos := fdata.Position; fData.WriteBuffer(buf, nRead); try 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; Numwritten:=Numwritten+FileBuf.bufSize; end; 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
Re: [twsocket] HTTP client relocation
> The question is: Should the HTTP client component implement this > relative path removal algorithm ? In my opinion it should. I've not reported it before, and I've lost my fix due to installing new ICS versions over the last month. But there is another problem in relocation when the relocation is to the same URL, and the component gets stuck in a loop. Again this is really a server issue, but letting their bug crash our application is not really on. Angus -- 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
[twsocket] HTTP client relocation
When using the url "http://mediaphor.louis.info/de/";, the HTTP client component hit a 404 error after a relocation. The problem is that the relocation is done to "../" so the component send the request "GET /de/../" and the server doesn't like it. In my opinion, it is a problem at server side. The same URL with IE work. Looking with a sniffer, I found that IE is removing the relative path before sending the request. So after relocation to "../", IE send the request "GET /" which is accepted by the remote server. The question is: Should the HTTP client component implement this relative path removal algorithm ? Contribute to the SSL Effort. Visit http://www.overbyte.be/eng/ssl.html -- [EMAIL PROTECTED] The author for the freeware multi-tier middleware MidWare The author of the freeware Internet Component Suite (ICS) http://www.overbyte.be -- 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