I read the man page and went through this example for usage: https://banu.com/blog/2/how-to-use-epoll-a-complete-example-in-c/, but I can't figure a way to do what I am trying to do using epoll, can anyone lend me some help?
Basically I am writing a netcat type utility to better learn C/networking. I have created a basic server/client that can listen and connect on one port. Now I want to expand the server aspect to listen on a port range.
I plan to do this via a for loop for each port creating socket(), bind(), and listen().
Since port range can be up to 65k, I need to poll them and accept() when one has a connection request received.
Unlinke typical C servers that use poll or epoll to deal with multiple connections on one port, this is one connection on one of several thousand potential ports. I can't quite get from the examples how I could epoll the sockets and when a connection is requested accept it and unbind/stop listening/polling.
Has anyone got any example explanations/code to get me started please?