开发者

Conventional way of accepting connections in a proactive web-server (using asynchronous IO)

开发者 https://www.devze.com 2023-03-08 14:53 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号