Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

POSIX Sockets

Name: Anonymous 2013-09-29 11:08

Is it better to use poll(2) or select(2)?

I've always used select(2) in my daemons, but I'm finding poll(2) designs to be far cleaner, since I don't have to do all the FD_SET nonsense on every call and it keeps the descriptor, requested events and activated events all in the same structure that is fed directly to the call.

Is poll(2) more performant? I know there's kqueue, epoll, and all that other shit, but I'm not going to use something platform specific. Seems like poll(2) works on BSD and Linux in the same way, though I've not done any proper testing.

What do you all use?

Name: Anonymous 2013-09-29 13:11

poll(2) is better design-wise, but you might run into portability issues. Unless you're making an application for Plan 9 or TempleOS, you should be fine using poll(2)

Name: Anonymous 2013-09-29 18:16

select() is an unintuitive and unnecessarily complicated clusterfuck of structs.

poll() uses a struct with just the socket and the flags you want to check on it.

Name: Anonymous 2013-09-29 18:21

poll() SCALES linearly (array of pollfd structs), while select() relies on #defined bitmasks/macros for representing pretty much everything, which makes it a pain in the ass and probably won't be linear to the number of sockets you use.

Like >>2-san says, use poll() (or any other event-based library if you like bloat) unless you want to bite off your dick in frustration.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List