您现在的位置: 论文网 >> 免费论文 >> 计算机论文 >> 计算机应用 >> 论文正文→使用indy的IdTcpServer,IdTcpclient传输文件
使用indy的IdTcpServer,IdTcpclient传输文件
作者:未知     文章出处:论文网     发布时间:2007-4-12
-
使用indy的IdTcpServer,IdTcpclient传输文件
 

接受部分(有个用户和密码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 传输文件 密码 
相关文章列表:
  • 利用鼠标键盘钩子截获密码

  • “不可破译”的密码

  • 如果觉得本篇论文可以,点击收藏本文! [收藏到ViVi] [收藏到365Key] [返回顶部↑]
    站内搜索
    本篇论文关键词
    indy IdTcpServer IdTcpclient
    传输文件 密码 
    论文推荐阅读
    论文点击排行
    论文网调查
    论文网服务