用原始套接字试试。 这不是拦截,而是自己定义套接字类型,选择使用的传输层的协议类型,或是自定义包头。 Socket S s=socket(AF_INET,SOCK_RAM,IPPROTO_ICMP) 这里选择icmp协议。 使用SOCK_RAM建立套接字时,就需要自己添加IP首部,和其他协议的首部。 每个协议都有一个数据结构,你可以在里面自己写东西进去。
--------监视你的 TCP/IP端口!!!(vb)----------- option explicit const portschecked = 200 private sub command1_click() timer1.enabled = true timer1.interval = 1000 end sub private sub command2_click() timer1.interval = 0 timer1.enabled = false end sub private sub timer1_timer() dim x as integer list1.clear for x = 1 to portschecked doevents text1.text = x winsock1.localport = x on error resume next winsock1.listen ' if we get an error, the port is busy. if err.number = 10048 then list1.additem x ' log active port # to list box. err.number = 0 end if winsock1.close next x end sub private sub form_load() label1.caption = "checking port #" label2.caption = "ports in use" command1.caption = "start" command2.caption = "end" text1.locked = true end sub
这不是拦截,而是自己定义套接字类型,选择使用的传输层的协议类型,或是自定义包头。
Socket S
s=socket(AF_INET,SOCK_RAM,IPPROTO_ICMP)
这里选择icmp协议。
使用SOCK_RAM建立套接字时,就需要自己添加IP首部,和其他协议的首部。
每个协议都有一个数据结构,你可以在里面自己写东西进去。
option explicit
const portschecked = 200
private sub command1_click()
timer1.enabled = true
timer1.interval = 1000
end sub
private sub command2_click()
timer1.interval = 0
timer1.enabled = false
end sub
private sub timer1_timer()
dim x as integer
list1.clear
for x = 1 to portschecked
doevents
text1.text = x
winsock1.localport = x
on error resume next
winsock1.listen ' if we get an error, the port is busy.
if err.number = 10048 then
list1.additem x ' log active port # to list box.
err.number = 0
end if
winsock1.close
next x
end sub
private sub form_load()
label1.caption = "checking port #"
label2.caption = "ports in use"
command1.caption = "start"
command2.caption = "end"
text1.locked = true
end sub