Fórum Transferencia de arquivos pela internet #239888
26/06/2004
0
D@rk_sun
Curtir tópico
+ 0Posts
27/06/2004
D@rk_sun
Gostei + 0
27/06/2004
Jasig Aurumalfa
Mas não recomendo muito para programas como FTP, e também no caso de seu programa, use outra porta para o FTP, não sendo 21, para evitar conflitos...
Gostei + 0
27/06/2004
Jasig Aurumalfa
Mas não recomendo muito para programas como [b:e3f3cd5d96]FTP[/b:e3f3cd5d96][/quote:e3f3cd5d96]
Eu quis dizer ICQ...
Gostei + 0
27/06/2004
Jasig Aurumalfa
usada no ServerSocket receber e salvar o arquivo recebido:
No Servidor:
var TInfo:PTrasnferInfo; p,r:Integer; Dta,f:string; Buffer:array [1..256] of Char; begin Dta:=Socket.ReceiveText; if Socket.Data = nil then begin try New(TInfo); f:=Chr(13); p:=Pos(f,Dta); TInfo^.LocalFile:=Copy(Dta,1,p - 1); if LstUploads.Items.IndexOf(UpperCase(TInfo^.LocalFile)) >= 0 then begin Socket.SendText(´O arquivo está sendo usado...´); Exit; end; TInfo^.Action:=TTransferAction(StrToIntDef(Copy(Dta,p + 1,Length(Dta)),0)); if TInfo^.Action = taDownload then begin AssignFile(TInfo^.BFile,TInfo^.LocalFile); Reset(TInfo^.BFile); end else if TInfo^.Action = taUpload then begin AssignFile(TInfo^.TFile,TInfo^.LocalFile); ReWrite(TInfo^.TFile); LstUploads.Items.Add(UpperCase(TInfo^.LocalFile)); end; Socket.Data:=TInfo; if TInfo^.Action = taDownload then Socket.SendText(IntToStr(FileSize(TInfo^.BFile))) else if TInfo^.Action = taUpload then Socket.SendText(´C´); except Socket.SendText(´Não foi possível acessar o arquivo´); Exit; end; end else begin TInfo:=Socket.Data; if TInfo^.Action = taDownload then begin p:=FilePos(TInfo^.BFile); BlockRead(TInfo^.BFile,Buffer,256,r); r:=FileSize(TInfo^.BFile); Dta:=string(Buffer); if (r - p) < 256 then Dta:=Copy(Dta,1,r - p); Socket.SendText(Dta); end else if TInfo^.Action = taUpload then begin Write(TInfo^.TFile,Dta); Socket.SendText(´C´); end; end; end;
Espero ter ajudado...
Gostei + 0
28/06/2004
D@rk_sun
Gostei + 0
30/06/2004
D@rk_sun
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)