szSystemStatus As String * 128 iMaxSockets As Integer iMaxUdpDg As Integer lpVendorInfo As Long End Type
'sock 地址结构 Public Type sockaddr sin_family As Integer sin_port As Integer sin_addr As Long sin_zero As String * 8 End Type
Public Type HOSTENT h_name As Long h_aliases As Long h_addrtype As Integer h_length As Integer h_addr_list As Long End Type
'ip 头结构 Public Type ipheader lenver As Byte tos As Byte len As Integer ident As Integer flags As Integer ttl As Byte proto As Byte checksum As Integer sourceIP As Long destIP As Long End Type
'TCP 头结构 Public Type tcp_hdr th_sport As Integer th_dport As Integer th_seq As Long th_ack As Long th_lenres As Byte th_flag As Byte th_win As Integer th_sum As Integer th_urp As Integer End Type
'UDP 头结构 Public Type udp_hdr th_sport As Integer th_dport As Integer th_len As Integer th_sum As Integer End Type
'ICMP 头结构 Public Type icmp_hdr th_type As Byte th_code As Byte th_sum As Integer th_id As Integer th_seq As Integer th_time As Long End Type
'常量 Public Const PF_INET = 2 Public Const SOCK_RAW = 3 Public Const AF_INET = 2 Public Const FD_READ = &H1 Public Const SIO_RCVALL = &H98000001 Public Const EM_REPLACESEL = &HC2
Public host As HOSTENT Public s As Long Public sock As sockaddr
Public Header As ipheader Public tcpHead As tcp_hdr Public udpHead As udp_hdr Public icmpHead As icmp_hdr
Public resarray() As Long, str As String Public i As Long, CountID As Long 'i 为临时变量,循环语句用,CountID 用来计算一共有多少个数据包 Public protocol As String Public buffer() As Byte '存放数据包 Public res As Long '返回值,临时变量 Public ExitID As Boolean '退出标识
'开始 Public Sub Wstartup() Dim Data As WSAdata Call WSAstartup(&H202, Data) '初始化 Winsock 为 2.2 End Sub
'结束 Public Sub WCleanup(s As Long) Call WsACleanup '关闭 Winsock closesocket s End Sub
'获得当前主机的 IP Public Function ip(ByRef address As String) As String Dim pip As Long Dim uip As Long Dim s As Long Dim ss As String Dim cul As Long