主单元:Unit1.pas
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp;
type
TForm1 = class(TForm)
Edit1: TEdit;
ClientSocket1: TClientSocket;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Buff: array [0..10239] of Char;
begin
ClientSocket1.Host := Edit1.Text;
FillChar(Buff, 10240, 0);
ClientSocket1.Open;
ClientSocket1.Socket.SendBuf(Buff, 10240);
ClientSocket1.Close;
end;
end.
主窗口:Unit1.dfm
object Form1: TForm1
Left = 192
Top = 55
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 8
Top = 8
Width = 121
Height = 21
TabOrder = 0
Text = '202.108.255.203'
end
object Button1: TButton
Left = 136
Top = 6
Width = 75
Height = 25
Caption = 'Send'
Default = True
TabOrder = 1
OnClick = Button1Click
end
object ClientSocket1: TClientSocket
Active = False
ClientType = ctNonBlocking
Port = 80
Left = 176
end
end
工程文件:project1.dpr
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.