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

Pages: 1-

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.

Name: Anonymous 2013-09-29 22:47

>>2-4
Thanks!

Not sure why I didn't start using poll() before. I've always hated select().

Name: Anonymous 2013-09-30 10:29

>>1-5,7-1000
Thank you so very much, I would have never found out about poll. I've also always hated select.

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