监听所有端口

huangapple go评论84阅读模式
英文:

Listen from all the ports

问题

我正在编写一个程序,它可以监听从一个接口发送出去的所有数据包。我已经阅读了net的文档,但是我在那里找到的所有可能的方法都需要以host:port的形式提供addr参数。我想要读取从一个网络接口发送出去的所有数据包。你有什么建议吗?

英文:

I'm writing a program which listen all the packets which come out from an interface. I've read the net godoc but all the possible methods I've found there require the addr in the form host:port. I would read all the packets which go out from one network interface. Do you have any suggestions?

答案1

得分: 2

你无法一次绑定到所有端口而不单独监听它们,我相信这不是你在问题的最后一句话中的意思。

我认为你真正需要的是一个数据包捕获库,比如gopacket/pcap

英文:

You can't bind to all ports at once without listening on them separately, and I'm pretty sure that's not what you mean in the last sentence of your question.

I think what you're really after is a packet capture library, like gopacket/pcap.

huangapple
  • 本文由 发表于 2016年11月8日 07:28:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/40476513.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定