需要异步 I/O 处理
计划在 Linux 上通过 aio* 调用使用异步 I/O
情况:
我已经使用 AF_INET 和 SOCK_STREAM 标志(TCP)打开了套接字
发送缓冲区有限制高水位线
想要异步写入该套接字,并且当发送缓冲区溢出时,想要断开套接字
所以,我有疑问:
当我在 TCP 套接字上对 aio_write 进行异步调用时,I/O 完成何时到达 - 缓冲区何时写出到套接字缓冲区或确认交付?我该如何管理这种行为?
如何最好地使用 lio_listio 技术来处理这个问题
问候,
安德鲁
你想避免在 Linux 上使用 AIO,至少现在是这样,从aio(7):
The current Linux POSIX AIO implementation is provided in userspace by glibc. This has a number of limitations, most notably that maintaining multiple threads to perform I/O operations is expensive and scales poorly. Work has been in progress for some time on a kernel state-machine-based implementation of asynchronous I/O (see io_submit(2)
, io_setup(2)
, io_cancel(2)
, io_destroy(2)
, io_getevents(2)
), but this implementation hasn't yet matured to the point where the POSIX AIO implementation can be completely reimplemented using the kernel system calls.
相反,请查看非阻塞 IOselect(2)/poll(2)/epoll(7).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)