N
nhivy
Unregistered / Unconfirmed
GUEST, unregistred user!
大家好:
我用D7编了一个通信程序。使用ClientSocket控件。在跟服务器通信方面已OK。
并能通过clientsocket1.Socket.SendText(Edit1.text+#13);向服务器发送命令。
我用Memo1.Lines.Add(socket.ReceiveText);接收并显示,问题就在这里。显示结果与现实有出入。
例如Edit1发送 ALLIP:ACL=A1;
在接收服务器返回结果却变成
ALLIP:ACL=A
1;
或
ALLIP:
ACL=A1;
将本来一行的字符断开成两行。
命令为:EXEDP:EMG=SSD0,EM=ALL;
接收结果:
<
EXEDP:E
MG=SSD0,EM=ALL;
EMGEM SOFTWARE UNIT AND EQUIPMENT DATA
EMG
SSD0
EM SUNAME SUID
EQM
0 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-0
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-0
JTR 1D11/CAA 117 1036/M57A R3A01 JT-0&&-31
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-0&&-7
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-0&&-127
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-288
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-0
1 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR
1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-1
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-1
JTR 1D11/CAA 117 1036/M57A R3A01 JT-32&&-63
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-8&&-15
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-128&
&-255
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-289
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-1
2 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-2
CD1R 1D12/CAA
117 1062/M57J R2A01 CD-2
JTR 1D11/CAA 117 1036/M57A R3A01 JT-64&&-95
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-16&&-23
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-256&&-383
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-290
SLCT2R 1313/CAA 117 1160/MK1
C R2A04 SLCT-2
END
<
正常显示为:
<
EXEDP:EMG=SSD0,EM=ALL;
EMGEM SOFTWARE UNIT AND EQUIPMENT DATA
EMG
SSD0
EM SUNAME SUID
EQM
0 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-0
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-0
JTR 1D11/CAA 117 1036/M57A R3A01 JT-0&&-31
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-0&&-7
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-0&&-127
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-288
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-0
1 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-1
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-1
JTR 1D11/CAA 117 1036/M57A R3A01 JT-32&&-63
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-8&&-15
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-128&&-255
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-289
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-1
2 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-2
CD1R 1D12/CAA117 1062/M57J R2A01 CD-2
JTR 1D11/CAA 117 1036/M57A R3A01 JT-64&&-95
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-16&&-23
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-256&&-383
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-290
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-2
END
<
数据显示很整齐的。请问有没有人见过这中情况?而且一行变两行显示的位置不定。
代码如下:
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(socket.ReceiveText);
end;
procedure TForm1.connectClick(Sender: TObject);
begin
ClientSocket1.Active:=True;
end;
procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
MessageDlg('服务器连接发生错误,请检查网络情况!',mtError,[mbok],0);
end;
procedure TForm1.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_return then
clientsocket1.Socket.SendText(edit1.text+#13);
end;
我用D7编了一个通信程序。使用ClientSocket控件。在跟服务器通信方面已OK。
并能通过clientsocket1.Socket.SendText(Edit1.text+#13);向服务器发送命令。
我用Memo1.Lines.Add(socket.ReceiveText);接收并显示,问题就在这里。显示结果与现实有出入。
例如Edit1发送 ALLIP:ACL=A1;
在接收服务器返回结果却变成
ALLIP:ACL=A
1;
或
ALLIP:
ACL=A1;
将本来一行的字符断开成两行。
命令为:EXEDP:EMG=SSD0,EM=ALL;
接收结果:
<
EXEDP:E
MG=SSD0,EM=ALL;
EMGEM SOFTWARE UNIT AND EQUIPMENT DATA
EMG
SSD0
EM SUNAME SUID
EQM
0 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-0
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-0
JTR 1D11/CAA 117 1036/M57A R3A01 JT-0&&-31
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-0&&-7
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-0&&-127
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-288
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-0
1 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR
1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-1
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-1
JTR 1D11/CAA 117 1036/M57A R3A01 JT-32&&-63
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-8&&-15
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-128&
&-255
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-289
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-1
2 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-2
CD1R 1D12/CAA
117 1062/M57J R2A01 CD-2
JTR 1D11/CAA 117 1036/M57A R3A01 JT-64&&-95
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-16&&-23
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-256&&-383
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-290
SLCT2R 1313/CAA 117 1160/MK1
C R2A04 SLCT-2
END
<
正常显示为:
<
EXEDP:EMG=SSD0,EM=ALL;
EMGEM SOFTWARE UNIT AND EQUIPMENT DATA
EMG
SSD0
EM SUNAME SUID
EQM
0 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-0
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-0
JTR 1D11/CAA 117 1036/M57A R3A01 JT-0&&-31
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-0&&-7
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-0&&-127
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-288
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-0
1 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-1
CD1R 1D12/CAA 117 1062/M57J R2A01 CD-1
JTR 1D11/CAA 117 1036/M57A R3A01 JT-32&&-63
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-8&&-15
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-128&&-255
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-289
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-1
2 TEETR 2/CAA 117 067/1 C R1A01
EMGFDR 1400/CAA 117 054/1I R2A01
REPER 1000/CAA 117 2501/1K R1A01
TSR 1DKA/CAA 117 1209/M57R R3A05 TS-2
CD1R 1D12/CAA117 1062/M57J R2A01 CD-2
JTR 1D11/CAA 117 1036/M57A R3A01 JT-64&&-95
KR2R 1EAK/CAA 117 1154/MK1D R3A02 KR2-16&&-23
LI33R 1340/CAA 117 1171/MK1A R2A07 LI3-256&&-383
SSTONER 1EAA/CAA 117 1141/MK1C R3A07 SSTONE-290
SLCT2R 1313/CAA 117 1160/MK1C R2A04 SLCT-2
END
<
数据显示很整齐的。请问有没有人见过这中情况?而且一行变两行显示的位置不定。
代码如下:
procedure TForm1.ClientSocket1Read(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(socket.ReceiveText);
end;
procedure TForm1.connectClick(Sender: TObject);
begin
ClientSocket1.Active:=True;
end;
procedure TForm1.ClientSocket1Error(Sender: TObject;
Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer);
begin
MessageDlg('服务器连接发生错误,请检查网络情况!',mtError,[mbok],0);
end;
procedure TForm1.Edit2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_return then
clientsocket1.Socket.SendText(edit1.text+#13);
end;