PING一个IP地址(向它发送一个数据包并等待回应))

安安的男人

安安的男人

2016-02-19 21:09

图老师小编精心整理的PING一个IP地址(向它发送一个数据包并等待回应))希望大家喜欢,觉得好的亲们记得收藏起来哦!您的支持就是小编更新的动力~
本例演示了怎样通过API的调用向一个IP地址发送一个包的数据并等待回音。
  新建一个工程,添加一个标准模块,写入以下代码:
  
  OptionExplicit
  
  PublicConstIP_STATUS_BASE=11000
  PublicConstIP_SUCCESS=0
  PublicConstIP_BUF_TOO_SMALL=(11000 1)
  PublicConstIP_DEST_NET_UNREACHABLE=(11000 2)
  PublicConstIP_DEST_HOST_UNREACHABLE=(11000 3)
  PublicConstIP_DEST_PROT_UNREACHABLE=(11000 4)
  PublicConstIP_DEST_PORT_UNREACHABLE=(11000 5)
  PublicConstIP_NO_RESOURCES=(11000 6)
  PublicConstIP_BAD_OPTION=(11000 7)
  PublicConstIP_HW_ERROR=(11000 8)
  PublicConstIP_PACKET_TOO_BIG=(11000 9)
  PublicConstIP_REQ_TIMED_OUT=(11000 10)
  PublicConstIP_BAD_REQ=(11000 11)
  PublicConstIP_BAD_ROUTE=(11000 12)
  PublicConstIP_TTL_EXPIRED_TRANSIT=(11000 13)
  PublicConstIP_TTL_EXPIRED_REASSEM=(11000 14)
  PublicConstIP_PARAM_PROBLEM=(11000 15)
  PublicConstIP_SOURCE_QUENCH=(11000 16)
  PublicConstIP_OPTION_TOO_BIG=(11000 17)
  PublicConstIP_BAD_DESTINATION=(11000 18)
  PublicConstIP_ADDR_DELETED=(11000 19)
  PublicConstIP_SPEC_MTU_CHANGE=(11000 20)
  PublicConstIP_MTU_CHANGE=(11000 21)
  PublicConstIP_UNLOAD=(11000 22)
  PublicConstIP_ADDR_ADDED=(11000 23)
  PublicConstIP_GENERAL_FAILURE=(11000 50)
  PublicConstMAX_IP_STATUS=11000 50
  PublicConstIP_PENDING=(11000 255)
  PublicConstPING_TIMEOUT=200
  PublicConstWS_VERSION_REQD=&H101
  PublicConstWS_VERSION_MAJOR=WS_VERSION_REQD&H100And&HFF&
  PublicConstWS_VERSION_MINOR=WS_VERSION_REQDAnd&HFF&
  PublicConstMIN_SOCKETS_REQD=1
  PublicConstSOCKET_ERROR=-1
  
  PublicConstMAX_WSADescription=256
  PublicConstMAX_WSASYSStatus=128
  
  PublicTypeICMP_OPTIONS
  TtlAsByte
  TosAsByte
  FlagsAsByte
  OptionsSizeAsByte
  OptionsDataAsLong
  EndType
  
  DimICMPOPTAsICMP_OPTIONS
  
  PublicTypeICMP_ECHO_REPLY
  AddressAsLong
  statusAsLong
  RoundTripTimeAsLong
  DataSizeAsInteger
  ReservedAsInteger
  DataPointerAsLong
  OptionsAsICMP_OPTIONS
  DataAsString*250
  EndType
  
  PublicTypeHOSTENT
  hNameAsLong
  hAliasesAsLong
  hAddrTypeAsInteger
  hLenAsInteger
  hAddrListAsLong
  EndType
  
  PublicTypeWSADATA
  wVersionAsInteger
  wHighVersionAsInteger
  szDescription(0ToMAX_WSADescription)AsByte
  szSystemStatus(0ToMAX_WSASYSStatus)AsByte
  wMaxSocketsAsInteger
  wMaxUDPDGAsInteger
  dwVendorInfoAsLong
  EndType
  
  PublicDeclareFunctionIcmpCreateFileLib"icmp.dll"()AsLong
  PublicDeclareFunctionIcmpCloseHandleLib"icmp.dll"(ByValIcmpHandleAsLong)AsLong
  PublicDeclareFunctionIcmpSendEchoLib"icmp.dll"(ByValIcmpHandleAsLong,ByValDestinationAddressAsLong,ByValRequestDataAsString,ByValRequestSizeAsInteger,ByValRequestOptionsAsLong,ReplyBufferAsICMP_ECHO_REPLY,ByValReplySizeAsLong,ByValTimeoutAsLong)AsLong
  PublicDeclareFunctionWSAGetLastErrorLib"WSOCK32.DLL"()AsLong
  PublicDeclareFunctionWSAStartupLib"WSOCK32.DLL"(ByValwVersionRequiredAsLong,lpWSADATAAsWSADATA)AsLong
  PublicDeclareFunctionWSACleanupLib"WSOCK32.DLL"()AsLong
  PublicDeclareFunctiongethostnameLib"WSOCK32.DLL"(ByValszHostAsString,ByValdwHostLenAsLong)AsLong
  PublicDeclareFunctiongethostbynameLib"WSOCK32.DLL"(ByValszHostAsString)AsLong
  PublicDeclareSubRtlMoveMemoryLib"kernel32"(hpvDestAsAny,ByValhpvSourceAsLong,ByValcbCopyAsLong)
  
  PublicFunctionGetStatusCode(statusAsLong)AsString
  
  DimmsgAsString
  
  SelectCasestatus
  CaseIP_SUCCESS:msg="ipsuccess"
  CaseIP_BUF_TOO_SMALL:msg="ipbuftoo_small"
  CaseIP_DEST_NET_UNREACHABLE:msg="ipdestnetunreachable"
  CaseIP_DEST_HOST_UNREACHABLE:msg="ipdesthostunreachable"
  CaseIP_DEST_PROT_UNREACHABLE:msg="ipdestprotunreachable"
  CaseIP_DEST_PORT_UNREACHABLE:msg="ipdestportunreachable"
  CaseIP_NO_RESOURCES:msg="ipnoresources"
  CaseIP_BAD_OPTION:msg="ipbadoption"
  CaseIP_HW_ERROR:msg="iphw_error"
  CaseIP_PACKET_TOO_BIG:msg="ippackettoo_big"
  CaseIP_REQ_TIMED_OUT:msg="ipreqtimedout"
  CaseIP_BAD_REQ:msg="ipbadreq"
  CaseIP_BAD_ROUTE:msg="ipbadroute"
  CaseIP_TTL_EXPIRED_TRANSIT:msg="ipttlexpiredtransit"
  CaseIP_TTL_EXPIRED_REASSEM:msg="ipttlexpiredreassem"
  CaseIP_PARAM_PROBLEM:msg="ipparam_problem"
  CaseIP_SOURCE_QUENCH:msg="ipsourcequench"
  CaseIP_OPTION_TOO_BIG:msg="ipoptiontoo_big"
  CaseIP_BAD_DESTINATION:msg="ipbaddestination"
  CaseIP_ADDR_DELETED:msg="ipaddrdeleted"
  CaseIP_SPEC_MTU_CHANGE:msg="ipspecmtuchange->

展开更多 50%)
分享

猜你喜欢

PING一个IP地址(向它发送一个数据包并等待回应))

编程语言 网络编程
PING一个IP地址(向它发送一个数据包并等待回应))

编写一个JAVA小程序取得IP地址

编程语言 网络编程
编写一个JAVA小程序取得IP地址

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

MySQL中文参考手册-- 创造并使用一个数据库

编程语言 网络编程
MySQL中文参考手册-- 创造并使用一个数据库

产后亲密 时机需要一个等待

月子
产后亲密 时机需要一个等待

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

把sql数据和access数据整合成一个数据集

编程语言 网络编程
把sql数据和access数据整合成一个数据集

从数据库中读取一个图片并保存为一个图片文件

Web开发
从数据库中读取一个图片并保存为一个图片文件

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

教小朋友认识红绿灯

教小朋友认识红绿灯

好看的伤感分组名称_我们各自不扰各自安好

好看的伤感分组名称_我们各自不扰各自安好
下拉加载更多内容 ↓