IdTCPClient和IdTCPserver消息传送问题(50分)

  • 主题发起人 主题发起人 zylsoft
  • 开始时间 开始时间
Z

zylsoft

Unregistered / Unconfirmed
GUEST, unregistred user!
type
//消息头
PDY_HEAD_tag = ^TCTKP_HEAD_tag;
TDY_HEAD_tag = record
Command: String[20]; //命令类型
end;

//消息体
PDY_CONNECT_tag = ^TCTKP_CONNECT_tag;
TDY_CONNECT_tag =record
Film_mc,
Film_zl,
Film_yy,
Film_xx,
Film_dy,
Film_cd,
Film_fx,
Film_js:String[50]
end;

T_init = record
head: TDY_HEAD_tag;
body: TDY_CONNECT_tag;
end;

IdTCPserver接收IdTCPClient的Command总是乱码?请教!!!!
 
IdTCPClient发生消息:

var init: T_init;

init.head.Command_ID:='FILMCX';
FmThread.IdTCPClient.WriteBuffer(init,Sizeof(init),True);

IdTCPserver接受消息:
if not AThread.Terminated and AThread.Connection.Connected then
begin
AThread.Connection.ReadBuffer(init,Sizeof(init));
Memo1.Lines.Add(init.head.Command_ID);
end;

接受乱码,请教!!!
 
自己解决了!!!
 
................
PDY_HEAD_tag = ^TCTKP_HEAD_tag;
TDY_HEAD_tag = record
Command: array[1..20] of char; //命令类型
end;
..............
TDY_CONNECT_tag =record
Film_mc,
Film_zl,
Film_yy,
Film_xx,
Film_dy,
Film_cd,
Film_fx,
Film_js:array[1..50] of char;
..............
 
后退
顶部