Ich versuche über telnet mit einem Host zu kommunizieren.
Das Verbinden funkioniert. Ich empfange zwar auch etwas, aber nur 'Rummel'. Das Senden scheint zwar auch zu funktionieren, aber der Host reagiert nicht.
Code: Alles auswählen
void DialogDriverSettings::on_pushButton_4_clicked()
{
m_pTcpSocket = new QTcpSocket(this);
connect(m_pTcpSocket, SIGNAL(connected()),
this, SLOT(connected()));
connect(m_pTcpSocket, SIGNAL(readyRead()),
this, SLOT(readyRead()));
m_pTcpSocket->connectToHost("172.31.255.2",23);
m_pTcpSocket->waitForConnected();
QTimer::singleShot(2000, this, SLOT(sockWrite()));
}
void DialogDriverSettings::connected()
{
qDebug() << "DialogDriverSettings::connected()";
}
void DialogDriverSettings::readyRead()
{
qDebug() << m_pTcpSocket->readAll();
}
void DialogDriverSettings::sockWrite()
{
qDebug() << "sockWrite:" << m_pTcpSocket->write("dir\r\n");
}
Die empfangenen Daten sehen so aus:DialogDriverSettings::connected()
"ÿû"
"ÿû"
sockWrite: 5
Wo liegt da das Problem?[0] -1 / 255 char
[1] -5 / 251 char
[2] 1 char