您现在的位置: 论文网 >> 计算机论文 >> 计算机应用论文 >> 使用indy的IdTcpServer,IdTcpclient传输文件论文

使用indy的IdTcpServer,IdTcpclient传输文件

作者:未知
出处:论文网
时间:2007-04-12
 

接受部分(有个用户和密码check,你取消就可以)
procedure TTCP_Server.IdTCPServerExecute(AThread: TIdPeerThread);
var
 FStream  : TFileStream;
 FileName  : String;
 CmdStr   : String;
begin
  CmdStr :=AThread.Connection.ReadLn();
  if CompareStr(Copy(CmdStr,1,6),'<SEND>')=0 then
   begin //1
    Delete(CmdStr,1,6);
    Cmd := '上传文件';
    FileName := CmdStr;
    if FileExists(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
  else if CompareStr(Copy(CmdStr,1,6),'<AGET>')=0 then
   begin //2
    Delete(CmdStr,1,6);
    Cmd := '下载文件';
    FileName := CmdStr;
    if FileExists(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
  else if CompareStr(Copy(CmdStr,1,6),'<USER>')=0 then
   begin //3
    Delete(CmdStr,1,6);
    User := UpperCase(Trim(DecryptString(CmdStr,20504))); //CmdStr;
    if CompareStr(User,'XDM')=0 then
      begin
       Memo1.Lines.Add('User: '+User);
       CmdStr :='';
      end
    else
      begin
       Memo1.Lines.Add('User: '+User+' 非法登陆,已关闭连接');
       CmdStr := '';
       AThread.Connection.WriteLn('<Failed>');
       AThread.Connection.Disconnect;
      end;
   end  //3
  else if CompareStr(Copy(CmdStr,1,6),'<PASS>')=0 then
   begin //4

 [1] [2] 下一页

论文搜索
关键字:indy IdTcpServer IdTcpclient 传输文件 密码
最新计算机应用论文
基于网络信息安全技术管理的计算机应用研究
浅析人工智能体系建设
抖音短视频平台视频推荐模式研究
应用电子技术中可编程控制器的应用探讨
用友NC信息系统的实施应用实践研究
基于校园一卡通数据系统的学生行为分析研究
云环境下基于蚁群算法的动态容错技术研究
自拍图像中的记忆痕迹
抖音短视频用户使用动机研究
基于创新扩散理论的Vlog传播
热门计算机应用论文
学生成绩管理系统的设计与实现
浅析计算机病毒及防范的措施
学籍管理系统软件
对计算科学与计算机发展的思考
计算机应用型人才的培养模式研究
物资管理信息系统开发
计算机信息管理在第三方物流中的应用
嵌入式系统数字图像采集接口电路设计
基于B/S体系结构开发应用系统
项目管理在软件中的应用