Conventional way of accepting connections in a proactive web-server (using asynchronous IO)
I'm currently exploring the aio on linux to use it for implementing a web-server. As I have already discovered, there are not too many resources that cover in detail the usage of aio.
The question is -- what is the conventional way of accepting the client connections in a single-threaded application that uses aio? (with minimum blocking possible)
Ideally, I can see aio_accept operation sending a notification (callback function call in my case) that the connection is established and the aio_read is called at once inside the开发者_Python百科 handler. But there is no such call :(
Thanks!
I don't think aio works on pre-accept sockets.
You probably want to select on them, or perhaps get SIGIO when it is ready.
[edit]
Specifically the man page says: "The device on which the file is opened must allow the seek operation. I.e., it is not possible to use any of the AIO operations on devices like terminals where an lseek call would lead to an error."
Sockets do not allow the seek operation, so even post-accept sockets would seem out of luck.
精彩评论