Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想为socket可以写一个android系统服务器。我目前正在设计这个,想知道是否有任何方法可以在不调用 read() 的情况下获取 Linux/POSIX 套接字上的数据并随时轮询结果。
是的,有几种方法可以做到这一点,其中包括 i/o 多路复用、信号驱动 i/o 和异步 i/o。
对于您的目的,多路复用可能就足够了,而且它是迄今为止最容易实现和正确的。调查select、poll或epoll 有大量可用的文章、参考资料和示例,并且这里不乏问题/答案来帮助您入门。大多数常见的编程语言都有公开这些服务的机制。