?? rdservermain.pas.~10~
字號:
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;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
procedure ToolButton3Click(Sender: TObject);
procedure Memo1DblClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure IdTCPServer1Execute(AThread: TIdPeerThread);
procedure IdTCPServer1Disconnect(AThread: TIdPeerThread);
procedure IdTCPServer1Connect(AThread: TIdPeerThread);
procedure ToolButton1Click(Sender: TObject);
private
{ Private declarations }
bmpScreen: TBitmap;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ToolButton1Click(Sender: TObject);
begin
IdTCPServer1.DefaultPort := 1111;
try
if not IdTCPServer1.Active then
begin
IdTCPServer1.Active := True;
ToolButton1.Caption := '停止服務'
end else begin
IdTCPServer1.Active := False;
ToolButton1.Caption := '打開服務';
end;
except
on e: Exception do
ShowMessage(e.Message);
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;
procedure TForm1.IdTCPServer1Execute(AThread: TIdPeerThread);
var
ms: TMemoryStream;
buf: array[0..1023] of Char;
begin
(*ms := TMemoryStream.Create;
AThread.Connection.ReadStream(ms,-1,true);
ms.Position := 0;
ms.ReadBuffer(buf,ms.Size);
Memo1.Lines.Add(buf);
ms.Free; *)
if AThread.Connection.ReadLn()= 'Request_Send' then
begin
Memo1.Lines.Add('接收請求命令: Request_Send');
Memo1.Lines.Add('發送關閉命令');
AThread.Connection.Disconnect;
end else
begin
Memo1.Lines.Add('接收Err')
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
bmpScreen := TBitmap.Create;
bmpScreen.Width := Screen.Width;
bmpScreen.Height:= Screen.Height;
Image1.Width := Screen.Width;
Image1.Height := Screen.Height;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
bmpScreen.Free;
end;
procedure TForm1.Memo1DblClick(Sender: TObject);
begin
Memo1.Clear;
end;
procedure TForm1.ToolButton3Click(Sender: TObject);
begin
// IdTCPServer1
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -