News for hackers. Stuff that matters.
Re:Using select(2) the right way by peterwwillis on Monday June 05, 2017 @12:35AM (#14485283)
The correct way to use select() is not to use it. You should instead use a library designed to do at a high level whatever it was you were going to use select() for. This library will then (hopefully) figure out what your application needs as efficiently as it can, rather than you having to spend a week researching how modern operating systems work to finally learn that you should have been using a library to do what you were about to try to reinvent.
Re:Using select(2) the right way by linkregister on Monday June 05, 2017 @01:19AM (#14485411)
Are there really no applications for using low-level async I/O APIs/syscalls? Embedded systems? Game servers? Proxies? Software routers? Hidden command & control servers?
Re:Using select(2) the right way by MrBuddyCasino on Monday June 05, 2017 @05:47AM (#14486336)
For embedded systems, LWIP has a socket API that supports select(). Try finding an event library for that one! I had to roll my own, and I learned quite a bit in the process.
Re:Using select(2) the right way by Matthias247 on Monday June 05, 2017 @09:34AM (#14487456)
Actually if you use the low-level LWIP (sometimes called Raw API) instead of the socket API it will be actually event-driven (singlethreaded, callback-driven, etc.) by design. The socket abstraction layer on top of it then provides blocking APIs and multithreading support - with the cost of a lower performance.
Re:Using select(2) the right way by MrBuddyCasino on Monday June 05, 2017 @12:20PM (#14488821)
I'm planning to eventually migrate to the netconn API, but was deterred by a lack of documentation. Do you know of any sources? This doesn't help much: http://www.nongnu.org/lwip/2_0_x/index.html
Re:Using select(2) the right way by Matthias247 on Monday June 05, 2017 @04:35PM (#14491669)
I also had quite some hard time with the lack of documentation for LWIP. The only other source that I found was the Wiki which is also linked there: http://lwip.wikia.com/wiki/LwIP_Wiki

But I still had to figure out lots of things from the actual code.

Re:Using select(2) the right way by MrBuddyCasino on Tuesday June 06, 2017 @03:17AM (#14495374)
Rats. I had a feeling you'd say that, thanks!
Re:Using select(2) the right way by Matthias247 on Wednesday June 07, 2017 @03:46AM (#14504401)
I found something more in my work bookmarks: http://www.atmel.com/Images/Atmel-42233-Using-the-lwIP-Netwo...

Maybe it also has some extra information which can help.

Re:Using select(2) the right way by MrBuddyCasino on Wednesday June 07, 2017 @10:20AM (#14506629)
Thanks!
Re:Using select(2) the right way by peterwwillis on Monday June 05, 2017 @01:30AM (#14485431)
So in other words, when is it appropriate to avoid using a pre-coded, pre-tested, independently-supported, documented, stable set of code designed to work in a variety of situations as well as it can? When it's not designed for what you need it to do. But i/o libraries are designed for all cases of select() I can think of.

The only time you shouldn't use a library, then, is when it literally doesn't work for you. In that case you should modify the library to add support for what you need, get it upstream, and use the library. Even if you decide using a library isn't right for you, you should at least read the source code of a library to see how they would have done it.

Re:Using select(2) the right way by linkregister on Monday June 05, 2017 @01:48AM (#14485480)
You're right with this comment. There have been times when I would have benefitted by looking at a library's code even when it didn't fit what I was trying to do.

What libraries do you recommend to replace async io system calls in C?

Re:Using select(2) the right way by loeg on Monday June 05, 2017 @02:09AM (#14485555)
The libevent family of libraries -- libevent, libev, libuv.
Re:Using select(2) the right way by pbat on Monday June 05, 2017 @01:55AM (#14485506)
check out libev: http://software.schmorp.de/pkg/libev.html

scales well, has a decent API.