【发布时间】:2011-12-16 13:13:15
【问题描述】:
为了使用 pcap 从多个接口中嗅探,我会执行以下操作(在伪代码中):
foreach interface:
open a file descriptor using pcap_open_live()
set the file descriptor to non-blocking
while true:
check for a ready file descriptor using select() or an equivalent I/O multiplexer
read data from every ready file descriptor using pcap_dispatch()
handle EndOfStream or Errors and break out of loop if needed
这是否足够或有一些特别的注意事项需要考虑?
【问题讨论】: