本文整理汇总了C++中QTcpSocket::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QTcpSocket::parent方法的具体用法?C++ QTcpSocket::parent怎么用?C++ QTcpSocket::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTcpSocket
的用法示例。
在下文中一共展示了QTcpSocket::parent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closeProxySocket
/**
* 接続を閉じる
*/
void YASWebProxy::closeProxySocket()
{
QTcpSocket* proxySocket = qobject_cast<QTcpSocket*>(sender());
if (proxySocket) {
QTcpSocket* socket = qobject_cast<QTcpSocket*>(proxySocket->parent());
if (socket)
socket->disconnectFromHost();
proxySocket->deleteLater();
}
}
示例2: closeConnection
/*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*/
void WebProxy::closeConnection() {
QTcpSocket *proxySocket = qobject_cast<QTcpSocket*>(sender());
if (proxySocket) {
QTcpSocket *socket = qobject_cast<QTcpSocket*>(proxySocket->parent());
if (socket)
socket->disconnectFromHost();
if (proxySocket->error() != QTcpSocket::RemoteHostClosedError)
qWarning() << "Error for:" << proxySocket->property("url").toUrl() << proxySocket->errorString();
proxySocket->deleteLater();;
}
} //WebProxy::closeConnection
示例3: onProxySocketConnectedHttps
void HttpProxy::onProxySocketConnectedHttps()
{
QTcpSocket *proxySocket = qobject_cast<QTcpSocket *>(sender());
QTcpSocket *socket = qobject_cast<QTcpSocket *>(proxySocket->parent());
disconnect(socket, &QTcpSocket::readyRead, this, &HttpProxy::onSocketReadyRead);
/* once it's connected, we use a light-weight SocketStream class to do the job */
SocketStream *stream = new SocketStream(socket, proxySocket, this);
connect(socket, &QTcpSocket::disconnected, stream, &SocketStream::deleteLater);
connect(stream, &SocketStream::info, this, &HttpProxy::info);
static const QByteArray httpsHeader = "HTTP/1.0 200 Connection established\r\n\r\n";
socket->write(httpsHeader);
}
示例4: forwardResponse
/**
* レスポンスを転送する
*/
void YASWebProxy::forwardResponse()
{
QTcpSocket* proxySocket = qobject_cast<QTcpSocket*>(sender());
QTcpSocket* socket = qobject_cast<QTcpSocket*>(proxySocket->parent());
QByteArray res = proxySocket->readAll();
HttpParser* parser = proxySocket->findChild<HttpParser*>("responseParser");
if (parser != 0) {
parser->input(res);
socket->write(parser->dequeueData());
} else {
socket->write(res);
}
}
示例5: onProxySocketReadyRead
void HttpProxy::onProxySocketReadyRead()
{
QTcpSocket *proxySocket = qobject_cast<QTcpSocket *>(sender());
QTcpSocket *socket = qobject_cast<QTcpSocket *>(proxySocket->parent());
socket->write(proxySocket->readAll());
}
示例6: transferData
/*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*/
void WebProxy::transferData() {
QTcpSocket *proxySocket = qobject_cast<QTcpSocket*>(sender());
QTcpSocket *socket = qobject_cast<QTcpSocket*>(proxySocket->parent());
socket->write(proxySocket->readAll());
} //WebProxy::transferData