Board index » delphi » Re: What's the best way to update your app
Remy Lebeau (TeamB)
Delphi Developer |
Remy Lebeau (TeamB)
Delphi Developer |
Re: What's the best way to update your app2006-02-21 05:36:30 PM delphi152 "tBS" <XXXX@XXXXX.COM>writes QuoteI couldn't find the file using TClientSocket, it is says file not found. implement was faulty to begin with. Please show your actual code. Quotewhy The ClientSocket didn't work? |
tBS
Delphi Developer |
2006-02-22 10:01:48 AM
Re: What's the best way to update your appQuoteTClientSocket has no concept of the HTTP protocol at all, which means that TCP.Open s := 'GET /myfile.exe HTTP/1.0'#13#10 + 'Host: www.mywebsite.com'+#13#10#13#10; intReturnCode:=TCP.WriteBuffer(Pchar(s), Length(s)); Assign(f, 'EBILL1.exe'); Rewrite(f,1); if intReturnCode>0 then begin {receive the answer} { iterate until no more data } while (intReturnCode>0) do begin { clear buffer before each iteration } FillChar(Buffer, SizeOf(Buffer), 0); { try to receive some data } intReturnCode := TCP.ReadBuffer(@Buffer, SizeOf(Buffer)); BytesRec:=BytesRec+ Length(Buffer); SendMessage(HStatusBar, SB_SETText, 0, integer(inttostr(BytesRec)+' Bytes received')); { if received a some data, then add this data to the result string } if intReturnCode>0 then BlockWrite(f, Buffer, Sizeof(Buffer)); end; end; Close(f); Note that I am using traditional socket using win32 API no VCL tBS |
Remy Lebeau (TeamB)
Delphi Developer |
2006-02-23 08:45:26 AM
Re: What's the best way to update your app
"tBS" <XXXX@XXXXX.COM>writes
QuoteTCP:=TTCPClient.Create; Also, I *STRONGY* recommend that you NOT use TTCPClient at all. It is a very poorly implemented component. Use TClientSocket instead (yes, it is still available even though it was deprecated in D7). A better approach would be to use a real HTTP component instead, such as the one from Indy (www.indyproject.org), ICS (www.overbyte.be), or Synapse (www.ararat.cz/synapse). Quotes := 'GET /myfile.exe HTTP/1.0'#13#10 + QuoteintReturnCode:=TCP.WriteBuffer(Pchar(s), Length(s)); Quote{receive the answer} socket is file data only. That is not the case. QuoteNote that I am using traditional socket using win32 API no VCL |