高分请教 网中有一台202.32.56.112。我想测一下跟它通不通。怎么能做到。最好说明原理和实现方法。分不够。再加+++在线等。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ping命令--详细帮助 校验与远程计算机或本地计算机的连接。只有在安装 TCP/IP 协议之后才能使用该命令。ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos] [-r count] [-s count] [[-j computer-list] | [-k computer-list]] [-w timeout] destination-list 参数 -t 校验与指定计算机的连接,直到用户中断。 -a 将地址解析为计算机名。 -n count 发送由 count 指定数量的 ECHO 报文,默认值为 4。 -l length 发送包含由 length 指定数据长度的 ECHO 报文。默认值为 64 字节,最大值为 8192 字节。 -f 在包中发送“不分段”标志。该包将不被路由上的网关分段。 -i ttl 将“生存时间”字段设置为 ttl 指定的数值。 -v tos 将“服务类型”字段设置为 tos 指定的数值。 -r count 在“记录路由”字段中记录发出报文和返回报文的路由。指定的 Count 值最小可以是 1,最大可以是 9 。 -s count 指定由 count 指定的转发次数的时间邮票。 -j computer-list 经过由 computer-list 指定的计算机列表的路由报文。中间网关可能分隔连续的计算机(松散的源路由)。允许的最大 IP 地址数目是 9 。 -k computer-list 经过由 computer-list 指定的计算机列表的路由报文。中间网关可能分隔连续的计算机(严格源路由)。允许的最大 IP 地址数目是 9 。 -w timeout 以毫秒为单位指定超时间隔。 destination-list 指定要校验连接的远程计算机。 关于 Ping 的详细信息 Ping--注意 Ping 命令通过向计算机发送 ICMP 回应报文并且监听回应报文的返回,以校验与远程计算机或本地计算机的连接。对于每个发送报文, Ping 最多等待 1 秒,并打印发送和接收把报文的数量。比较每个接收报文和发送报文,以校验其有效性。默认情况下,发送四个回应报文,每个报文包含 64 字节的数据(周期性的大写字母序列)。可以使用 Ping 实用程序测试计算机名和 IP 地址。如果能够成功校验 IP 地址却不能成功校验计算机名,则说明名称解析存在问题。这种情况下,要保证在本地 HOSTS 文件中或 DNS 数据库中存在要查询的计算机名。下面显示 Ping 输出的示例:(Windows用户可用:开始->运行,输入"command" 调出command窗口使用此命令)C:\>ping ds.internic.netPinging ds.internic.net [192.20.239.132] with 32 bytes of data:Reply from 192.20.239.132: bytes=32 time=101ms TTL=243Reply from 192.20.239.132: bytes=32 time=100ms TTL=243Reply from 192.20.239.132: bytes=32 time=120ms TTL=243Reply from 192.20.239.132: bytes=32 time=120ms TTL=243 你可以动态创建一个idHttp来测试,delphi下有个pingGui的例子,看看 Example 1 (code snippet): uses Ping;...const ADP_IP = '208.185.127.40'; (* http://delphi.about.com *)begin If Ping.Ping(ADP_IP) then ShowMessage('About Delphi Programming reachable!');end; unit Ping;interfaceuses Windows, SysUtils, Classes;type TSunB = packed record s_b1, s_b2, s_b3, s_b4: byte; end; TSunW = packed record s_w1, s_w2: word; end; PIPAddr = ^TIPAddr; TIPAddr = record case integer of 0: (S_un_b: TSunB); 1: (S_un_w: TSunW); 2: (S_addr: longword); end; IPAddr = TIPAddr;function IcmpCreateFile : THandle; stdcall; external 'icmp.dll';function IcmpCloseHandle (icmpHandle : THandle) : boolean; stdcall; external 'icmp.dll'function IcmpSendEcho (IcmpHandle : THandle; DestinationAddress : IPAddr; RequestData : Pointer; RequestSize : Smallint; RequestOptions : pointer; ReplyBuffer : Pointer; ReplySize : DWORD; Timeout : DWORD) : DWORD; stdcall; external 'icmp.dll';function Ping(InetAddress : string) : boolean;implementationuses WinSock;function Fetch(var AInput: string; const ADelim: string = ' '; const ADelete: Boolean = true) : string;var iPos: Integer;begin if ADelim = #0 then begin // AnsiPos does not work with #0 iPos := Pos(ADelim, AInput); end else begin iPos := Pos(ADelim, AInput); end; if iPos = 0 then begin Result := AInput; if ADelete then begin AInput := ''; end; end else begin result := Copy(AInput, 1, iPos - 1); if ADelete then begin Delete(AInput, 1, iPos + Length(ADelim) - 1); end; end;end;procedure TranslateStringToTInAddr(AIP: string; var AInAddr);var phe: PHostEnt; pac: PChar; GInitData: TWSAData;begin WSAStartup($101, GInitData); try phe := GetHostByName(PChar(AIP)); if Assigned(phe) then begin pac := phe^.h_addr_list^; if Assigned(pac) then begin with TIPAddr(AInAddr).S_un_b do begin s_b1 := Byte(pac[0]); s_b2 := Byte(pac[1]); s_b3 := Byte(pac[2]); s_b4 := Byte(pac[3]); end; end else begin raise Exception.Create('Error getting IP from HostName'); end; end else begin raise Exception.Create('Error getting HostName'); end; except FillChar(AInAddr, SizeOf(AInAddr), #0); end; WSACleanup;end;function Ping(InetAddress : string) : boolean;var Handle : THandle; InAddr : IPAddr; DW : DWORD; rep : array[1..128] of byte;begin result := false; Handle := IcmpCreateFile; if Handle = INVALID_HANDLE_VALUE then Exit; TranslateStringToTInAddr(InetAddress, InAddr); DW := IcmpSendEcho(Handle, InAddr, nil, 0, nil, @rep, 128, 0); Result := (DW <> 0); IcmpCloseHandle(Handle);end;end. 如何把宽带连接设置为共享? 向其他应用程序窗口的文本框写数据 菜鸟正在学习listview1的拖放功能,只是在listview1和listview2之间相互拖放已经实现了,可我又放了1个listview3.... Ado连接数据库服务器问题 进制转化小问题 关于DBlookupcombobox控件的问题? 想学习fastreport设计报表,原一直用quickreport 请问一个有关ftp客户端编写的问题 hook messagebox 关于Dbgrid的简单问题 请教如何将ClientDataSet用于两层结构。 一个困扰我许久的业务问题
校验与远程计算机或本地计算机的连接。只有在安装 TCP/IP 协议之后才能使用该命令。ping [-t] [-a] [-n count] [-l length] [-f] [-i ttl] [-v tos] [-r count] [-s count] [[-j computer-list] | [-k computer-list]] [-w timeout] destination-list 参数 -t 校验与指定计算机的连接,直到用户中断。 -a 将地址解析为计算机名。 -n count 发送由 count 指定数量的 ECHO 报文,默认值为 4。 -l length 发送包含由 length 指定数据长度的 ECHO 报文。默认值为 64 字节,最大值为 8192 字节。 -f 在包中发送“不分段”标志。该包将不被路由上的网关分段。 -i ttl 将“生存时间”字段设置为 ttl 指定的数值。 -v tos 将“服务类型”字段设置为 tos 指定的数值。 -r count 在“记录路由”字段中记录发出报文和返回报文的路由。指定的 Count 值最小可以是 1,最大可以是 9 。 -s count 指定由 count 指定的转发次数的时间邮票。 -j computer-list 经过由 computer-list 指定的计算机列表的路由报文。中间网关可能分隔连续的计算机(松散的源路由)。允许的最大 IP 地址数目是 9 。 -k computer-list 经过由 computer-list 指定的计算机列表的路由报文。中间网关可能分隔连续的计算机(严格源路由)。允许的最大 IP 地址数目是 9 。 -w timeout 以毫秒为单位指定超时间隔。 destination-list 指定要校验连接的远程计算机。 关于 Ping 的详细信息 Ping--注意 Ping 命令通过向计算机发送 ICMP 回应报文并且监听回应报文的返回,以校验与远程计算机或本地计算机的连接。对于每个发送报文, Ping 最多等待 1 秒,并打印发送和接收把报文的数量。比较每个接收报文和发送报文,以校验其有效性。默认情况下,发送四个回应报文,每个报文包含 64 字节的数据(周期性的大写字母序列)。可以使用 Ping 实用程序测试计算机名和 IP 地址。如果能够成功校验 IP 地址却不能成功校验计算机名,则说明名称解析存在问题。这种情况下,要保证在本地 HOSTS 文件中或 DNS 数据库中存在要查询的计算机名。下面显示 Ping 输出的示例:(Windows用户可用:开始->运行,输入"command" 调出command窗口使用此命令)C:\>ping ds.internic.netPinging ds.internic.net [192.20.239.132] with 32 bytes of data:Reply from 192.20.239.132: bytes=32 time=101ms TTL=243Reply from 192.20.239.132: bytes=32 time=100ms TTL=243Reply from 192.20.239.132: bytes=32 time=120ms TTL=243Reply from 192.20.239.132: bytes=32 time=120ms TTL=243
...
const ADP_IP = '208.185.127.40'; (* http://delphi.about.com *)
begin
If Ping.Ping(ADP_IP) then
ShowMessage('About Delphi Programming reachable!');
end; unit Ping;interface
uses
Windows, SysUtils, Classes;type
TSunB = packed record
s_b1, s_b2, s_b3, s_b4: byte;
end; TSunW = packed record
s_w1, s_w2: word;
end; PIPAddr = ^TIPAddr;
TIPAddr = record
case integer of
0: (S_un_b: TSunB);
1: (S_un_w: TSunW);
2: (S_addr: longword);
end; IPAddr = TIPAddr;function IcmpCreateFile : THandle; stdcall; external 'icmp.dll';
function IcmpCloseHandle (icmpHandle : THandle) : boolean;
stdcall; external 'icmp.dll'
function IcmpSendEcho
(IcmpHandle : THandle; DestinationAddress : IPAddr;
RequestData : Pointer; RequestSize : Smallint;
RequestOptions : pointer;
ReplyBuffer : Pointer;
ReplySize : DWORD;
Timeout : DWORD) : DWORD; stdcall; external 'icmp.dll';
function Ping(InetAddress : string) : boolean;implementationuses
WinSock;function Fetch(var AInput: string;
const ADelim: string = ' ';
const ADelete: Boolean = true)
: string;
var
iPos: Integer;
begin
if ADelim = #0 then begin
// AnsiPos does not work with #0
iPos := Pos(ADelim, AInput);
end else begin
iPos := Pos(ADelim, AInput);
end;
if iPos = 0 then begin
Result := AInput;
if ADelete then begin
AInput := '';
end;
end else begin
result := Copy(AInput, 1, iPos - 1);
if ADelete then begin
Delete(AInput, 1, iPos + Length(ADelim) - 1);
end;
end;
end;procedure TranslateStringToTInAddr(AIP: string; var AInAddr);
var
phe: PHostEnt;
pac: PChar;
GInitData: TWSAData;
begin
WSAStartup($101, GInitData);
try
phe := GetHostByName(PChar(AIP));
if Assigned(phe) then
begin
pac := phe^.h_addr_list^;
if Assigned(pac) then
begin
with TIPAddr(AInAddr).S_un_b do begin
s_b1 := Byte(pac[0]);
s_b2 := Byte(pac[1]);
s_b3 := Byte(pac[2]);
s_b4 := Byte(pac[3]);
end;
end
else
begin
raise Exception.Create('Error getting IP from HostName');
end;
end
else
begin
raise Exception.Create('Error getting HostName');
end;
except
FillChar(AInAddr, SizeOf(AInAddr), #0);
end;
WSACleanup;
end;function Ping(InetAddress : string) : boolean;
var
Handle : THandle;
InAddr : IPAddr;
DW : DWORD;
rep : array[1..128] of byte;
begin
result := false;
Handle := IcmpCreateFile;
if Handle = INVALID_HANDLE_VALUE then
Exit;
TranslateStringToTInAddr(InetAddress, InAddr);
DW := IcmpSendEcho(Handle, InAddr, nil, 0, nil, @rep, 128, 0);
Result := (DW <> 0);
IcmpCloseHandle(Handle);
end;end.