[英]Asynchronous http client library and glib event loop
A am looking for an asynchronous http client library with some specific need:我正在寻找具有某些特定需求的异步 http 客户端库:
In order to impement it as a glibmm source, one must have access to its file descriptor, create a Glib::PollFD object, and I should be good to go.为了将它作为一个 glibmm 源来实现,必须能够访问它的文件描述符,创建一个 Glib::PollFD object,我应该对 go 很好。
I have been looking at several libraries, which all have some problems:我一直在查看几个库,它们都有一些问题:
Can anyone overcome the problems I see with these tree libraries, or suggest alternative libraries?任何人都可以克服我在这些树库中看到的问题,或者建议替代库吗?
Glib::PollFD::PollFD(int fd) is the constructor that you want. Glib::PollFD::PollFD(int fd) 是您想要的构造函数。 An fd_set is just a set of integer fds.
一个 fd_set 只是一组 integer fds。 The word "set" is used in the mathematical sense, ie no fd can occur more than once in a set, therefore they do not refer to it as an array or a list.
“集合”这个词是在数学意义上使用的,即 fd 在集合中不能出现多次,因此他们不将其称为数组或列表。 An fd_set is just a fixed size buffer.
fd_set 只是一个固定大小的缓冲区。 Try it out by making an fd_set and adding some fds to it, then look at it in a debugger or just dump it out in hex.
通过创建一个 fd_set 并向其中添加一些 fd 来尝试一下,然后在调试器中查看它,或者只是将其转储为十六进制。
This is a common patter in async programming where you need to join two async event loops.这是异步编程中的常见模式,您需要加入两个异步事件循环。 While you could poll two loops with a timeout, it is generally better to get the raw fds out of one event loop, and add them
虽然您可以轮询两个带有超时的循环,但通常最好将原始 fds 从一个事件循环中取出,然后添加它们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.