procedure TForm1.FormCreate(Sender: TObject);
begin
IdTCPServer1.DefaultPort := ;
IdTCPServer1.Active := True;
end; procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
mmo1.Lines.Add('来自主机 '+ AThread.Connection.Socket.Binding.PeerIP
+ ' 的连接请求已被接纳!');
end; procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
begin
mmo1.Lines.Add(AThread.Connection.ReadLn());
end; procedure TForm1.IdTCPServer1Disconnect(AThread: TIdPeerThread);
begin
mmo1.Lines.Add('来自主机 '+ AThread.Connection.Socket.Binding.PeerIP
+ ' 的连接请求已被断开!');
end; procedure TForm1.btnConnectClick(Sender: TObject);
begin
//IdTCPClient1.Host := '127.0.0.1';
IdTCPClient1.Host := '192.168.88.104';
IdTCPClient1.Port := StrToInt(edt1.Text);
mmo1.Lines.Add('正在连接 ' + edt1.Text + '...');
IdTCPClient1.Connect();
end; procedure TForm1.btnDisconnectClick(Sender: TObject);
begin
IdTCPClient1.Disconnect();
end; procedure TForm1.btnSendClick(Sender: TObject);
begin
IdTCPClient1.WriteLn(edt2.Text);
end;
05-11 19:40