L
loskiller
Unregistered / Unconfirmed
GUEST, unregistred user!
Client代码
procedure TForm1.Button1Click(Sender: TObject);
var
a:array[0..3] of char;
begin
a:='1234';
c.WriteBuffer(a,4,true);
end;
Server代码
procedure TForm1.sExecute(AThread: TIdPeerThread);
var
a:array[0..3] of char;
begin
caption:='nm';
if not AThread.Terminated and AThread.Connection.Connected then
begin
caption:='nm11';
AThread.Connection.ReadBuffer(a,4);
caption:=a;
//AThread.Connection.Disconnect;
end;
end;
如果我不加AThread.Connection.Disconnect的话,根本就读不出数据。而且每次退出客户端时,服务器都会报出异常。但是我看了Indy自带的列子,它好象没有断开连接啊。
procedure TForm1.Button1Click(Sender: TObject);
var
a:array[0..3] of char;
begin
a:='1234';
c.WriteBuffer(a,4,true);
end;
Server代码
procedure TForm1.sExecute(AThread: TIdPeerThread);
var
a:array[0..3] of char;
begin
caption:='nm';
if not AThread.Terminated and AThread.Connection.Connected then
begin
caption:='nm11';
AThread.Connection.ReadBuffer(a,4);
caption:=a;
//AThread.Connection.Disconnect;
end;
end;
如果我不加AThread.Connection.Disconnect的话,根本就读不出数据。而且每次退出客户端时,服务器都会报出异常。但是我看了Indy自带的列子,它好象没有断开连接啊。