用于C ++的简单异步多线程HTTP请求库 [英] Simple Asynchronous Multi-Threaded HTTP request library for C++

查看:1030
本文介绍了用于C ++的简单异步多线程HTTP请求库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会很快和诚实:我目前正在尝试为在线游戏编写客户端/服务器。由于我资源不足,资源有限,我将使用PHP后端测试服务器的裸机基础,最终目标是在C ++中重建服务器端。

I'll be quick and honest: I'm currently trying to write a client/server for an online game. Since I'm poor and limited on resources, I'll be testing the bare basics of the server using a PHP backend, with the eventual goal being to rebuild the server end in C++.

我正在寻找一个用于Windows(最好是XP和Vista)的C ++库,它将允许我使用有限数量的线程,一个专用于每一个网络问题。例如,我想使用线程来向服务器报告播放器的位置信息(并且接收关于其他播放器的位置信息的响应),但是我想要一个不同的线程到该区域的3D艺术品中进行背景下载/播放器,以及内置聊天系统的不同线程等。这些都需要相互独立。

I'm looking for a C++ library for Windows (XP and Vista preferably) that will let me use a finite number of threads, one dedicated to each piece of the networking problem. As an example, I want to use a thread to report the positional information of the player to the server (and to receive responses about positional information of the other players) but I want a different thread to background download in the 3D artwork for the area/players, and a different thread for the built in chat system, etc. These all need to be fairly independent of one another.

我知道我想要什么>做与图书馆,我有设计的位,我只是觉得有点傻重新发明的轮子,因为我知道一个良好的库这个确切的目的可能已经存在。那么,你的建议是什么?我需要能够发送数据到服务器,并接受响应。理想情况下,请求需要触发一个事件,当它完成(所以我可以立即抓取数据并做一些事情),我需要能够同时处理多个事务。 HTTP是一个不错的奖励,但是如果有必要,我可以自己处理HTTP协议,特别是考虑到我计划从长远来看它。

I know what I want to do with the library, I've got the design bit figured out, I just feel a bit silly re-inventing the wheel, since I know that a good library for this exact purpose probably already exists. So, what are your suggestions? I need to be able to send data to a server, and accept responses. Ideally, the request needs to trigger an Event when its done (so I can immediately grab the data and do something with it) and I need to be able to handle multiple transactions simultaneously. HTTP is a nice bonus, but I can handle HTTP protocol myself if necessary, especially considering that I plan on dropping it in the long run.

谢谢!

推荐答案

Boost.Asio

ASIO有简单的网络服务器示例。

ASIO has simple web server examples.

Boost.Thread

这篇关于用于C ++的简单异步多线程HTTP请求库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆