I have attached the code I am working on. As you can see I am establishing connection with the server and I am waiting for the response of it.
I am executing the command lb which lists me a set of commands. I have successfully established connection with the server, but I do not get the result for the command that I execute.
What I am trying to do is, I am establishing a telnet connection between my server and my code. I am trying to execute the commands indirectly from my code and process the output result obtained from the server.
char buffer[1024] = {0};
socket = new QTcpSocket(this);
QString hostaddress = "101.7324.156.19";
socket->connectToHost(hostaddress,23,QIODevice::ReadWrite);
if(socket->waitForConnected(3000))
{
qDebug() << "connected";
socket->write("lb");
socket->waitForBytesWritten(1000);
socket->waitForReadyRead(1000);
qDebug() << "reading" << socket->bytesAvailable();
socket->read(buffer,socket->bytesAvailable());
qDebug() << buffer << endl;
socket->close();
}
else
{
qDebug() << "not connected";
}