使用indy的IdTcpServer,IdTcpclient传輸文件【68字】_毕业论文

毕业论文移动版

毕业论文 > 计算机论文 >

使用indy的IdTcpServer,IdTcpclient传輸文件【68字】

接受部分(有个用户和密码check,你取消就可以)

procedureTTCP_Server。IdTCPServerExecute(AThread:TIdPeerThread);

var

FStream:TFileStream;

FileName论文网:String;

CmdStr:String;

begin

CmdStr:=AThread。Connection。ReadLn();

ifCompareStr(Copy(CmdStr,1,6),)=0then

begin//1

Delete(CmdStr,1,6);

Cmd:=上传文件;

FileName:=CmdStr;

ifFileExists(ExtractFilePath(Application。ExeName)+FileName)then

DeleteFile(ExtractFilePath(Application。ExeName)+FileName);

try

FStream:=TFileStream。Create(ExtractFilePath(Application。ExeName)+FileName,FmCreate);

AThread。Connection。ReadStream(FStream,2048,true);

Finally

FStream。Free;

AThread。Connection。Disconnect;

end;

end//1

elseifCompareStr(Copy(CmdStr,1,6),)=0then

begin//2

Delete(CmdStr,1,6);

Cmd:=下载文件;

FileName:=CmdStr;

ifFileExists(ExtractFilePath(Application。ExeName)+FileName)then

begin

try

FStream:=TFileStream。Create(ExtractFilePath(Application。ExeName)+FileName,FmOpenRead);

AThread。Connection。WriteStream(FStream,True,False);

Finally

FStream。Free;

AThread。Connection。Disconnect;

end;

end

else

begin

AThread。Connection。WriteLn(Failed);

AThread。Connection。Disconnect;

end;

end//2

elseifCompareStr(Copy(CmdStr,1,6),)=0then

begin//3

Delete(CmdStr,1,6);

User:=UpperCase(Trim(DecryptString(CmdStr,20504)));//CmdStr;

ifCompareStr(User,XDM)=0then

begin

Memo1。Lines。Add(User:+User);

CmdStr:=;

end

else

begin

Memo1。Lines。Add(User:+User+非法登陆,已关闭连接);

CmdStr:=;

AThread。Connection。WriteLn();

AThread。Connection。Disconnect;

end;

end//3

elseifCompareStr(Copy(CmdStr,1,6),)=0then

begin//4

[1][2]下一页

(责任编辑:qin)