procedure TfrmServer.ServerFileConnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s Connected', [AContext.Binding.IP]));
end;
procedure TfrmServer.ServerFileDisconnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s DisConnected', [AContext.Binding.IP]));
end;
server端显示的IP是0.0.0.0
服务端收到的信息是
Client 0.0.0.0 Connected
Client 0.0.0.0 DisConnected
求教了,多谢
3 个解决方案
#1
帖完整些,你帖的这个无关紧要,谁知道为啥
#2
客户端:
procedure TfrmTCPMain.FormCreate(Sender: TObject);
begin
with ClientMain do
begin
Host := '219.82.12.66';
Port := 9801;
ConnectTimeout := 60;
end;
end;
procedure TfrmTCPMain.btnConnectClick(Sender: TObject);
begin
with ClientMain do
begin
try
Connect;
except
;
end;
if Connected then
btnConnect.Enabled := False else
ShowMessage('连接失败');
end;
end;
服务端
procedure TfrmServer.FormCreate(Sender: TObject);
begin
ServerFile.DefaultPort := 9801;
end;
procedure TfrmServer.NStartClick(Sender: TObject);
begin
ServerFile.Active := True;
end;
procedure TfrmServer.ServerFileConnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s Connected', [AContext.Binding.IP]));
end;
procedure TfrmServer.ServerFileDisconnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s DisConnected', [AContext.Binding.IP]));
end;
procedure TfrmTCPMain.FormCreate(Sender: TObject);
begin
with ClientMain do
begin
Host := '219.82.12.66';
Port := 9801;
ConnectTimeout := 60;
end;
end;
procedure TfrmTCPMain.btnConnectClick(Sender: TObject);
begin
with ClientMain do
begin
try
Connect;
except
;
end;
if Connected then
btnConnect.Enabled := False else
ShowMessage('连接失败');
end;
end;
服务端
procedure TfrmServer.FormCreate(Sender: TObject);
begin
ServerFile.DefaultPort := 9801;
end;
procedure TfrmServer.NStartClick(Sender: TObject);
begin
ServerFile.Active := True;
end;
procedure TfrmServer.ServerFileConnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s Connected', [AContext.Binding.IP]));
end;
procedure TfrmServer.ServerFileDisconnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s DisConnected', [AContext.Binding.IP]));
end;
#3
跟踪的错误信息:
connection reset by peer
connection reset by peer
#1
帖完整些,你帖的这个无关紧要,谁知道为啥
#2
客户端:
procedure TfrmTCPMain.FormCreate(Sender: TObject);
begin
with ClientMain do
begin
Host := '219.82.12.66';
Port := 9801;
ConnectTimeout := 60;
end;
end;
procedure TfrmTCPMain.btnConnectClick(Sender: TObject);
begin
with ClientMain do
begin
try
Connect;
except
;
end;
if Connected then
btnConnect.Enabled := False else
ShowMessage('连接失败');
end;
end;
服务端
procedure TfrmServer.FormCreate(Sender: TObject);
begin
ServerFile.DefaultPort := 9801;
end;
procedure TfrmServer.NStartClick(Sender: TObject);
begin
ServerFile.Active := True;
end;
procedure TfrmServer.ServerFileConnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s Connected', [AContext.Binding.IP]));
end;
procedure TfrmServer.ServerFileDisconnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s DisConnected', [AContext.Binding.IP]));
end;
procedure TfrmTCPMain.FormCreate(Sender: TObject);
begin
with ClientMain do
begin
Host := '219.82.12.66';
Port := 9801;
ConnectTimeout := 60;
end;
end;
procedure TfrmTCPMain.btnConnectClick(Sender: TObject);
begin
with ClientMain do
begin
try
Connect;
except
;
end;
if Connected then
btnConnect.Enabled := False else
ShowMessage('连接失败');
end;
end;
服务端
procedure TfrmServer.FormCreate(Sender: TObject);
begin
ServerFile.DefaultPort := 9801;
end;
procedure TfrmServer.NStartClick(Sender: TObject);
begin
ServerFile.Active := True;
end;
procedure TfrmServer.ServerFileConnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s Connected', [AContext.Binding.IP]));
end;
procedure TfrmServer.ServerFileDisconnect(AContext: TIdContext);
begin
Memo1.Lines.Add(Format('Client %s DisConnected', [AContext.Binding.IP]));
end;
#3
跟踪的错误信息:
connection reset by peer
connection reset by peer