rdservermain.pas.~5~

来自「Indy9,客户端」· ~5~ 代码 · 共 62 行

~5~
62
字号
unit rdServerMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls, ToolWin, IdBaseComponent, IdComponent,
  IdTCPServer, StdCtrls;

type
  TForm1 = class(TForm)
    ToolBar1: TToolBar;
    ScrollBox1: TScrollBox;
    Image1: TImage;
    ToolButton1: TToolButton;
    IdTCPServer1: TIdTCPServer;
    Memo1: TMemo;
    procedure IdTCPServer1Disconnect(AThread: TIdPeerThread);
    procedure IdTCPServer1Connect(AThread: TIdPeerThread);
    procedure ToolButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ToolButton1Click(Sender: TObject);
begin
  IdTCPServer1.DefaultPort := 1111;
  try
    IdTCPServer1.Active := True;
  except

  end;

end;

procedure TForm1.IdTCPServer1Connect(AThread: TIdPeerThread);
begin
  with AThread.Connection.Socket.Binding do
  begin
    Memo1.Lines.Add(Format('%s: %d 已经登陆!',[PeerIP,PeerPort]))
  end;
end;

procedure TForm1.IdTCPServer1Disconnect(AThread: TIdPeerThread);
begin
  with AThread.Connection.Socket.Binding do
  begin
    Memo1.Lines.Add(Format('%s: %d 退出!',[PeerIP,PeerPort]))
  end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?