能帮我写段程序吗?我现在在外地上学没有环境调试!(100分)

I

ili

Unregistered / Unconfirmed
GUEST, unregistred user!
一个SOCKET程序~实现非常简单~在FORM上加个TEXT和个SOCKET~TEXT的TEXT属性为WINSOCK
的REMOTEHOST属性!然后主要实现向远程IP的80端口发送10K的0字节包~
 
up........
 
主单元: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.
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
1K
DelphiTeacher的专栏
D
D
回复
0
查看
940
DelphiTeacher的专栏
D
顶部