问题
Need an async I/O Processing
Plan to use async I/O through aio* calls on Linux
The situation:
I have opened socket with AF_INET and SOCK_STREAM flags (TCP) Have limit high watermark for send buffers Want to write to that socket asynchronously, and when send buffer overflows, want to disconnect an socket
So, I have questions:
When I made async call to aio_write on TCP socket, when I/O completion will arrives - when buffer written out into socket buffer or delivery is confirmed? How I can manage this behavior?
How's best to handle this with lio_listio techniques
Regards, Andrew
回答1:
You want to avoid AIO on Linux for anything real, at least for now, From 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 (seeio_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.
Instead, look into non-blocking IO with select(2)/poll(2)/epoll(7).
来源:https://stackoverflow.com/questions/9751345/asynchronous-i-o-linux