I am using UDP BSD sockets in C, and I need a way to receive all packets sent to my IP on a range of different port numbers. My current code can detect packets only on one port that I specify. Is this possible to do, or should I look for another way to accomplish this?
Asked
Active
Viewed 60 times
-1
-
Your current code such as what? – user207421 Dec 31 '20 at 06:00
-
Welcome to StackOverflow! See [minimal-reproducible-example](https://stackoverflow.com/help/minimal-reproducible-example) on how to create a minimal-reproducible-example. – wuerfelfreak Dec 31 '20 at 08:00
-
1Depending on your environment you might use raw sockets or you might firewall rules to redirect traffic destined for many ports to a single port (i.e. iptables redirect, pf divert etc) and thus get the traffic no matter what original port it was sent to. – Steffen Ullrich Dec 31 '20 at 10:28
1 Answers
0
You would need to start a listener for each port number you want to listen to

Matt Douhan
- 2,053
- 1
- 21
- 40
-
i didnt mention in my original post that iam using udp not tcp would that make a difference? – blinded_ravager Dec 31 '20 at 04:40
-
@blinded_ravager I doubt it, udp as well as tcp needs to listen to a specific port – Matt Douhan Dec 31 '20 at 06:14