首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

向网络编程高手请问Indy通信过程中出现的乱码有关问题 Indy V10.5.6

2012-02-03 
向网络编程高手请教Indy通信过程中出现的乱码问题Indy V10.5.6服务端:Procedure TInformationServer.OnTCP

向网络编程高手请教Indy通信过程中出现的乱码问题 Indy V10.5.6
服务端:
Procedure TInformationServer.OnTCPExecute(AContext: TIdContext);
var
  sCommand: string;
begin
  AContext.Connection.IOHandler.ReadLn(TIdTextEncoding.UTF8,TIdTextEncoding.UTF8);
  sCommand:=uppercase(AContext.Connection.IOHandler.ReadLn);
  If sCommand='FILELIST' then
  begin

  sCommand:=AContext.Connection.IOHandler.ReadLn;
  end;
  If fMemo<>nil Then
  fMemo.Lines.Add(sCommand);
end;


客户端:
  IdTCPClient1.Connect;
  IdTCPClient1.Socket.WriteLn(TIdTextEncoding.UTF8);
  IdTCPClient1.Socket.WriteLn('Filelist');
  IdTCPClient1.Socket.WriteLn('美女');
  IdTCPClient1.Disconnect;

以上代码纯粹做网络测试,程序中客户端能与服务端连通,服务端能收到"Filelist",但“美女”两个字无法收到!

[解决办法]
把这行注释掉试试。
IdTCPClient1.Socket.WriteLn(TIdTextEncoding.UTF8);

热点排行