ohh sure - but i fixed it already - this i shouldn't do of course. But it doesn't work anyway :-?
tcpsocket.cpp
CTcpSocket
::CTcpSocket(int socketDescriptor,
QObject *parent
), m_socketDescriptor(socketDescriptor)
{
if (!m_tcpSocket->setSocketDescriptor(m_socketDescriptor)) {
qDebug() << m_tcpSocket->error();
return;
}
connect(m_tcpSocket, SIGNAL(readyRead()), SLOT(readData()));
}
void CTcpSocket::readData()
{
//ToDo Implement reading Data
qDebug() << "try to read";
//m_tcpSocket->waitForReadyRead(10000);
}
void CTcpSocket
::writeData(QString txt
) {
qDebug() << "try to write";
out << (quint16)0;
out << txt;
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
m_tcpSocket->write(block);
m_tcpSocket->waitForBytesWritten(10000);
}
CTcpSocket::CTcpSocket(int socketDescriptor, QObject *parent)
: QObject(parent)
, m_socketDescriptor(socketDescriptor)
{
m_tcpSocket = new QTcpSocket();
if (!m_tcpSocket->setSocketDescriptor(m_socketDescriptor)) {
qDebug() << m_tcpSocket->error();
return;
}
connect(m_tcpSocket, SIGNAL(readyRead()), SLOT(readData()));
}
void CTcpSocket::readData()
{
//ToDo Implement reading Data
qDebug() << "try to read";
//m_tcpSocket->waitForReadyRead(10000);
}
void CTcpSocket::writeData(QString txt)
{
qDebug() << "try to write";
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << (quint16)0;
out << txt;
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
m_tcpSocket->write(block);
m_tcpSocket->waitForBytesWritten(10000);
}
To copy to clipboard, switch view to plain text mode
Bookmarks