在 C++ 中实现简单的服务器/客户端概念
我正在寻找一个库/框架/codenippet,它可以帮助我构建一个非常简单的服务器/客户端。两者都应该是可移植的(linux/win/mac)。
一张图胜过一千个字:
服务器应该能够区分不同的客户端。 我正在寻找的只是有关如何进行转移的提示。我对 C++ 以外的语言经验很少,创建一个服务器非常简单,该服务器将所有连接的客户端存储在一个数组中,并在您指向正确的方向后与每个客户端进行交互。
我对 C++ 的研究是 RakNet 和 Boost.Asio。 我不想使用 RakNet,因为我可能会在某个时候出售该应用程序(你永远不会知道),而 Boost.Asio 对我来说似乎太复杂,太低级了。我真正需要的是一个简单的发送/接收功能。 json 将由我处理(我已经研究过 jsoncpp)。一条消息的最大长度为 2048 字节。
关于要研究什么/要使用什么有什么建议/提示/帮助吗? 我真的在寻找一些简单的东西,而不是低级的使用,因为我不需要低级的功能。
预先感谢,
罗宾.
I'm searching for a library / framework / codesnippet that helps me build a really simple server / client. Both should be portable (linux/win/mac).
A picture says more then a thousand words so:
The server should be able to seperate diffrent clients.
What I'm looking for is only a hint on how to do the transfere. I've little experience with languages other then c++, and it was mostly plain easy to create a server that stores all the clients connected in an array and interacts with each one of them once you got pointed in the right direction.
What I looked into for C++ was RakNet and Boost.Asio.
I don't want to use RakNet because I might sell the application at some point (you never know) and Boost.Asio seems way to complex for me to understand and way to low-level. All I really need is a simple send/recieve functionallity.
The json will be handled by me (I already looked into jsoncpp). One message will have a maximum length of 2048 bytes.
Any suggestions / hints / help on what to look into / what to use?
I'm really looking for something easy and not so much low-level to use as I don't need the low-level functionallity.
Thanks in advance,
Robin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您以前做过网络编程吗?在 C 语言中它非常简单。并且您想要的可以在几个小时内实现。当我还是学生时,我使用下面的手册来完成我的作业。
http://shoe.bocks.com/net/
只需阅读本文即可开始。这确实不是很难。
祝你好运!
Have you done Network programming before? Its pretty straight forward in C. And what you want can be implemented in a few hours. I used this manual below to finish my assignments back when i was a student.
http://shoe.bocks.com/net/
Just read this and you are good to go. Its really not very hard.
Good Luck!
我喜欢Beej 的网络编程指南。
I enjoyed Beej's guide to network programming.
由于跨平台和易于使用都是我推荐 Qt 的要求。它非常简单、可靠且跨平台。
http://qt.nokia.com/products/developer-tools/
它来了有很多示例,包括 13 个网络示例(请查看线程服务器教程,我相信这正是您所追求的)。
As cross-platform and easy-to-use are both requirements I would recommend Qt. It's pretty easy, reliable and cross-platform.
http://qt.nokia.com/products/developer-tools/
It comes with lots of samples including 13 networking samples (take a look at the threaded server tutorial which I believe it's just what you're after).