R
redsky.l
Unregistered / Unconfirmed
GUEST, unregistred user!
看了http://www.gislab.ecnu.edu.cn/delphibbs/DispQ.asp?LID=499978贴子非常有感慨!!
所以贴出些贴!
首先申明,本人只是一个菜鸟,以下程序只是偶得提出供大家分享、讨论,以求共同提高。
Server.pas
————————————————————————————
unit Server;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, NMUDP, StdCtrls;
type
TForm1 = class(TForm)
SUDP: TNMUDP;
MainMenu1: TMainMenu;
WIndows1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
Edit2: TEdit;
StaticText1: TStaticText;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N17Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure N23Click(Sender: TObject);
private
procedure winexit(var msg:tmessage);message wm_queryendsession;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const BufSize=2048;
var
RsltStream,TmpStream:TMemoryStream;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
RsltStream:=TMemoryStream.Create;
TmpStream:=TMemoryStream.Create;
end;
procedure TForm1.winexit(var msg:tmessage);
begin
msg.Result:=1;
application.ProcessMessages;
application.Terminate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
RsltStream.Free;
TmpStream.Free;
end;
procedure TForm1.N1Click(Sender: TObject);
var
ReqCode:array[0..29] of char;
ReqCodeStr:string;
begin
ReqCodeStr:='restart';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N2Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='close';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N4Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='cscre';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N5Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='oscre';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N7Click(Sender: TObject);
var ReqCode:array[0..250] of char;ReqCodeStr:string;
xinxi:string;
begin
xinxi:=inputbox('请输入要发送的信息','信息','');
if xinxi<>'' then
begin
ReqCodeStr:='
所以贴出些贴!
首先申明,本人只是一个菜鸟,以下程序只是偶得提出供大家分享、讨论,以求共同提高。
Server.pas
————————————————————————————
unit Server;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Menus, NMUDP, StdCtrls;
type
TForm1 = class(TForm)
SUDP: TNMUDP;
MainMenu1: TMainMenu;
WIndows1: TMenuItem;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
N20: TMenuItem;
N21: TMenuItem;
N22: TMenuItem;
N23: TMenuItem;
Edit2: TEdit;
StaticText1: TStaticText;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N4Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N17Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure N21Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure N23Click(Sender: TObject);
private
procedure winexit(var msg:tmessage);message wm_queryendsession;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const BufSize=2048;
var
RsltStream,TmpStream:TMemoryStream;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
RsltStream:=TMemoryStream.Create;
TmpStream:=TMemoryStream.Create;
end;
procedure TForm1.winexit(var msg:tmessage);
begin
msg.Result:=1;
application.ProcessMessages;
application.Terminate;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
RsltStream.Free;
TmpStream.Free;
end;
procedure TForm1.N1Click(Sender: TObject);
var
ReqCode:array[0..29] of char;
ReqCodeStr:string;
begin
ReqCodeStr:='restart';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N2Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='close';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N4Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='cscre';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N5Click(Sender: TObject);
var ReqCode:array[0..29] of char;ReqCodeStr:string;
begin
ReqCodeStr:='oscre';
StrpCopy(ReqCode,ReqCodeStr);
TmpStream.Clear;
RsltStream.Clear;
SUDP.RemoteHost:=Edit2.Text;
SUDP.SendBuffer(ReqCode,30);
end;
procedure TForm1.N7Click(Sender: TObject);
var ReqCode:array[0..250] of char;ReqCodeStr:string;
xinxi:string;
begin
xinxi:=inputbox('请输入要发送的信息','信息','');
if xinxi<>'' then
begin
ReqCodeStr:='