当前位置:主页>销售管理软件> 列表

TCP-indy的问题 找药品进销存管理系统

销售管理软件版1楼: while not Sender.Terminated do
begin
if frm_Client.LDPClient.Connected then
try
Leng := frm_Client.LDPClient.ReadFromStack();
if Leng > 0 then
begin
frm_Client.LDPClient.ReadBuffer(Msg, SizeOf(MsgHeader));
case Msg.MsgType of
iRestart:
begin
frm_Client.LDPClient.Disconnect;
.......
end;
iUrgentFile:
begin
if frm_Client.LDPClient.ReadFromStack() > 0 then
frm_Client.LDPClient.ReadBuffer(MsgPlaylist, SizeOf(MsgPlayList));
....
end;
......

我这样做对不对
Server端发过来的包包含包头,还有body两部分,我在线程中先读去包头,判断什么包然后在按照body的类型来读,不管用不用if frm_Client.LDPClient.ReadFromStack() > 0 then
好像读出来都有问题,有时候读到的包的数据跟发的不一样,如果我一次性读就没有问题,难道不能分2次来读发过来的包吗?

2楼: 你的MsgHeader定义中是不是包含char类型的成员?? 如药品进销存管理系统

3楼: 没有用到char,
MsgHeader = packed record
MsgType: Integer;
end;
MsgCaption = packed record
Id: string[15];
Text: string[255];
begintime,
endtime: TDateTime;
end;

大概包都是这样

4楼: _MsgCaption = packed record
Head: MsgHeader;
Body: MsgCaption;
end;
大概都是这样,server就发这样的包过来,client先接包头,然后再试body
如果一起接就没有问题,分开就出问题

5楼: 我对于Indy组件也有很多的疑问不知道哪里有更多的关于这组控件的资料可以看到。

6楼: 顶一下

销售管理软件版7楼: 汗,原来是有个sizeof 里面的包名copy错了

8楼: 多人接受答案了。