antweb
16th April 2015, 08:20
void MyTcpSocket::doConnect()
{
socket = new QTcpSocket(this);
openrtspsetup = new QProcess(this);
connect(socket, SIGNAL(connected()),this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected()));
connect(socket, SIGNAL(bytesWritten(qint64)),this, SLOT(bytesWritten(qint64)));
connect(socket, SIGNAL(readyRead()),this, SLOT(readyRead()));
qDebug() << "connecting..."; // this is not blocking call
socket->setSocketOption(QAbstractSocket::KeepAliveOption,t rue);
socket->connectToHost("192.168.0.128", 554); // we need to wait...
if(!socket->waitForConnected(5000))
{ qDebug() << "Error: " << socket->errorString(); }
}
void MyTcpSocket::connected()
{
qDebug() << "connected...";
socket->write("OPTIONS rtsp://192.168.0.128:554 RTSP/1.0");
}
void MyTcpSocket::disconnected()
{
qDebug() << "disconnected...";
}
void MyTcpSocket::bytesWritten(qint64 bytes)
{
qDebug() << bytes << " bytes written...";
}
void MyTcpSocket::readyRead()
{
qDebug() << "reading..."; // read the data from the socket
qDebug() << socket->readAll();
}
void MyTcpSocket::on_pushButton_clicked()
{
socket->write("DESCRIBE rtsp://192.168.0.128:554 RTSP/1.0");
}
As soon as I am connected the first write on the socket works with an OK reply from server but if I don't press the button then it automatically disconnects in about 8-10 seconds.
Even if I do press the button it gives me a bad request and disconnects.
Why is KeepAlive not working. Also what is wrong with my describe statement?
Thanks.
{
socket = new QTcpSocket(this);
openrtspsetup = new QProcess(this);
connect(socket, SIGNAL(connected()),this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected()));
connect(socket, SIGNAL(bytesWritten(qint64)),this, SLOT(bytesWritten(qint64)));
connect(socket, SIGNAL(readyRead()),this, SLOT(readyRead()));
qDebug() << "connecting..."; // this is not blocking call
socket->setSocketOption(QAbstractSocket::KeepAliveOption,t rue);
socket->connectToHost("192.168.0.128", 554); // we need to wait...
if(!socket->waitForConnected(5000))
{ qDebug() << "Error: " << socket->errorString(); }
}
void MyTcpSocket::connected()
{
qDebug() << "connected...";
socket->write("OPTIONS rtsp://192.168.0.128:554 RTSP/1.0");
}
void MyTcpSocket::disconnected()
{
qDebug() << "disconnected...";
}
void MyTcpSocket::bytesWritten(qint64 bytes)
{
qDebug() << bytes << " bytes written...";
}
void MyTcpSocket::readyRead()
{
qDebug() << "reading..."; // read the data from the socket
qDebug() << socket->readAll();
}
void MyTcpSocket::on_pushButton_clicked()
{
socket->write("DESCRIBE rtsp://192.168.0.128:554 RTSP/1.0");
}
As soon as I am connected the first write on the socket works with an OK reply from server but if I don't press the button then it automatically disconnects in about 8-10 seconds.
Even if I do press the button it gives me a bad request and disconnects.
Why is KeepAlive not working. Also what is wrong with my describe statement?
Thanks.