QTcpServer: Send HTTP/1.0 200 OK to connected client
QTcpServer: Send HTTP/1.0 200 OK to connected client
我设置了一个QTcpServer来收听一个广播流。newConnection()信号被触发,因为它应该:
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(handleClientComm()));
void IcecastServer::handleClientComm(){
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
qDebug() << clientConnection->write("HTTP/1.0 200 OKrnrn" ) << endl;
clientConnection->flush();
}
如何发送HTTP 200
必须在发出newConnection()信号时使用nextPendingConnection()调用从QTcpServer中提取QTcpSocket对象。然后必须在提取的QTcpSocket对象上调用writeData()。
这里的关键是侦听套接字(QTcpServer)只负责在每次新客户端连接时创建连接套接字(或QTcpSocket)。QTcpSocket负责与特定客户端的实际通信。
也许你可以更具体地说什么对你不起作用,你尝试过什么?这也将是很好的,如果你能提供我们与wireshark PCAP,如果有些事情似乎不像预期的那样工作?
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- C++ Singleton - Prevent ::instance() to variable
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 尝试链接我的着色器时,我收到错误代码"error c5145 must write to gl_position"
- Python str to C++ to Python str
- 为什么创建友元类的实例会导致"undefined reference to"错误?
- System.InvalidCastException - SQL to C++ - safe_cast<float>
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- "no matching function for call to 'Vector::Vector'"错误
- vector<vector<double>> to mxArray using memcpy
- Tensorflow c++ api undefined reference to 'tflite::D efaultErrorReporter()'
- 当覆盖存在时调用基本虚拟"binded to object"函数
- 谷歌模拟 - 怎么说"function must be called ONCE with a certain parameter but ok to be called many times with
- 创建一个脚本,使我自动登录到由 IP URL 访问的网站,包括"click OK to logon"
- QTcpServer: Send HTTP/1.0 200 OK to connected client