c++ - 如何在Qt5中通过http连接到PUSH服务器

标签 c++ qt push qt5 qtnetwork

查看 QNetworkAccessManager 我没有看到任何与“推送”相关的内容。 http://qt-project.org/doc/qt-5/qnetworkaccessmanager-members.html 与 POST 或 GET 不同,使用“推送”http 连接时,您要保持连接,以便可以从服务器接收定期更新。 Qt5 中用于 HTTP REST“推送”客户端连接的正确函数是什么?或者可能是持久的 http 连接?

最佳答案

> How would I use QNetworkAccessManager to connect to an http push server?
<thiago> pEYEd: what HTTP command do you need to send?
> thiago good point. I am not sure. It looks like json  https://www.cryptsy.com/pages/pushapi
<thiago> pEYEd: JSON is not an HTTP command
<thiago> try again: what HTTP command do you need to send?
> i know
<thiago> pEYEd: let me try this: have you tried to simply get() the page?
> it looks like POST
> http://pusher.com/docs/client_api_guide/client_connect
<thiago> then use post()
> thiago will it automatically do a persistant connection?
<thiago> pEYEd: what exactly do you need to happen?
<thiago> it will keep giving you data as long as there's data to be given
> but it can't time out
<thiago> once the data ends, the connection may be closed or reused. But you cannot and must not care about it.
<thiago> there's no timeout mechanism in QNAM
> no FIN/ACK unless specified?
<thiago> that's at a much lower level
<thiago> the HTTP request/reply ends when the server says it ends
> the connection can't close. no fin/ack
<thiago> under HTTP/1.1, it ends when the number of bytes specified in Content-Length is reached
<thiago> or the chunked encoding says it's the last chunk
<thiago> if either of those conditions happen, the QNetworkReply signals the end
<thiago> then QNAM can do whatever it wants to the socket
> Thank you!

关于c++ - 如何在Qt5中通过http连接到PUSH服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24021321/

相关文章:

swift - 如何设置丰富通知的默认操作?

c++ - 调试错误,在c++中调用了abort()

c++ - 计算 vector<string> 中的单词出现次数

c++ - 覆盖 QAbstractItemModel::index 并访问 std::map

c++ - QImage::pixel() 没有正确返回透明度

Firebase - 通知点击事件未收到有效负载

c++ - TinyXML 在最后位置插入。

c++11:子类成员函数的 std::bind

qt - 在 Ubuntu Linux 上构建 QT 库

ios Firebase 推送通知项目