Question

I want to write a android system server for socket can. Im currently designing this and wondered if there is any way to get informed if data on a Linux/POSIX socket is available without calling read() and poll the result any time.

Was it helpful?

Solution

Yes, there are several ways to do this, among them i/o multiplexing, signal-drive i/o, and asynchronous i/o.

It's likely that for your purposes multiplexing will suffice and it is by far the easiest to implement and get right. Investigate select, poll or epoll There are an abundance of articles, references, and examples available and no shortage of questions/answers here to help you get started. Most common programming languages have a mechanism to expose these services.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top