将 boost::asio 的一部分包装在 C 库中 - 用于嵌入式 Linux
我正在寻找一个好的(且简单的)套接字库,可以将其合并到我正在用 C 语言为嵌入式 Linux 构建的 XMPP 客户端中。
很多人推荐了 boost::asio,并且由于我已经熟悉 C++ 和 boost 的某些方面 - 我想我可以将其包装到一个 C 库中,以便从我的代码中调用。
人们认为这与使用另一个套接字库相比有多困难——我只是让事情变得过于复杂了吗?
我看过简单套接字库(用 C 编写),但我发现它对于异步消息有点棘手。
关于我需要支持的接口的进一步说明(回答下面的评论): connect(ip, port)
close()
getIncomingMessage()
我还需要某种方式在发送数据时收到通知 - 轮询会过于密集,因为这对于仅定期获取数据发送的连接来说是最好长时间打开(直到有人关闭设备)。
I'm looking for a good ( and simple ) sockets library that I can incorporate into an XMPP client I am building in C for embedded Linux.
Lots of people have recommended boost::asio, and since I am already familiar with C++ and some aspects of boost - I thought I might wrap this up into a C library to be called from my code.
How difficult to people think this might be as opposed to using another sockets library - am I just overcomplicating things?
I have looked at Simple Sockets Library (written in C) but I find it a bit tricky for asynchronous messages.
Further clarification on the interface I need to support (to answer comment below):
connect(ip, port)
close()
getIncomingMessage()
I also need some way of being notified when something has been sent down the wire - polling would be too intensive as this is for a connection that only gets data sent down it periodically and is ideally open for a long time ( until someone turns off the device ).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用Boost ASIO 来实现C 接口听起来确实有点复杂并且不匹配。从更原生的 C 语言开始怎么样,比如 libevent?我知道这不一样,但它是一个开始,并且 C 本身很好地支持套接字编程。
Using Boost ASIO to implement a C interface does sound a bit complicated and mismatched. How about starting with something more native to C, like libevent? I know it's not the same, but it's a start, and socket programming is well supported in C itself.