F
formiss
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient;
type
TForm1 = class(TForm)
IdIcmpClient1: TIdIcmpClient;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
aBuffer: string;
begin
// IdIcmpClient1.Ping();
IdIcmpClient1.Host := 'http://www.every.com.cn';
// IdIcmpClient1.TTL := 64;
IdIcmpClient1.ReceiveTimeout := 1000;
try
IdIcmpClient1.Ping;
except on e:exception do
showMessage('false'+ e.Message );//报错: socket error #11004
end;
// showMessage(aBuffer);
// showMessage(IdIcmpClient1.ReplyData);
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
begin
try
if AReplyStatus.ReplyStatusType = rsError then
showMessage('false rsError')
else
showMessage('true');
except
showMessage('false except');
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdRawBase, IdRawClient,
IdIcmpClient;
type
TForm1 = class(TForm)
IdIcmpClient1: TIdIcmpClient;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
aBuffer: string;
begin
// IdIcmpClient1.Ping();
IdIcmpClient1.Host := 'http://www.every.com.cn';
// IdIcmpClient1.TTL := 64;
IdIcmpClient1.ReceiveTimeout := 1000;
try
IdIcmpClient1.Ping;
except on e:exception do
showMessage('false'+ e.Message );//报错: socket error #11004
end;
// showMessage(aBuffer);
// showMessage(IdIcmpClient1.ReplyData);
end;
procedure TForm1.IdIcmpClient1Reply(ASender: TComponent;
const AReplyStatus: TReplyStatus);
var
sTime: string;
begin
try
if AReplyStatus.ReplyStatusType = rsError then
showMessage('false rsError')
else
showMessage('true');
except
showMessage('false except');
end;
end;
end.