i want to say to the client what my server application should receive so understand what it should do. But i am not providing the client application.
Right now the client and the server i have done then,so i never care what happen when i do sth like this:
static QDataStream& operator<<(QDataStream& stream, structXX& xx)
{
stream << xx.n() <<xx.str()<<xx.ch();
}
static QDataStream
& operator>>
(QDataStream & stream, structXX
& xx
) {
qint32 n;
quint8 ch;
stream >> n;
stream >> str;
stream >> ch;
xx.set_n(n);
xx.set_str(str);
xx.set_ch(ch);
}
//on the socket class
qint32 socket::send(structXX &xx)
{
stream << (qint64) 0;
stream << xx;
stream.device()->seek(0);
stream << (qint64) (block.size() - sizeof(qint64));
m_Socket->write(block);
m_Socket->flush();
block.clear();
return 0;
}
void socket::slotReadyRead()
{
structXX xx;
if (m_lBlockSize == 0)
{
if (m_Socket->bytesAvailable() < (int) sizeof(qint64))
{
return;
}
stream >> m_lBlockSize;
}
if (m_Socket->bytesAvailable() < m_lBlockSize)
{
return;
}
stream >> message;
}
static QDataStream& operator<<(QDataStream& stream, structXX& xx)
{
stream << xx.n() <<xx.str()<<xx.ch();
}
static QDataStream& operator>>(QDataStream & stream, structXX& xx)
{
qint32 n;
QString str;
quint8 ch;
stream >> n;
stream >> str;
stream >> ch;
xx.set_n(n);
xx.set_str(str);
xx.set_ch(ch);
}
//on the socket class
qint32 socket::send(structXX &xx)
{
QByteArray block;
QDataStream stream(&block, QIODevice::WriteOnly);
stream << (qint64) 0;
stream << xx;
stream.device()->seek(0);
stream << (qint64) (block.size() - sizeof(qint64));
m_Socket->write(block);
m_Socket->flush();
block.clear();
return 0;
}
void socket::slotReadyRead()
{
structXX xx;
QDataStream stream(m_Socket);
if (m_lBlockSize == 0)
{
if (m_Socket->bytesAvailable() < (int) sizeof(qint64))
{
return;
}
stream >> m_lBlockSize;
}
if (m_Socket->bytesAvailable() < m_lBlockSize)
{
return;
}
stream >> message;
}
To copy to clipboard, switch view to plain text mode
So now what i want is to give a set of "strings" to the customer so he can implement the client application by hes own.
thanks for answers
Bookmarks