Hi all,
I'm amateur programmer of, but I must developpe an network-application with socket which side-client write by VC++ and side-server write by QT4. I'm tried many ways, and they could realize themselves but the connection is not understanding thoroughly, so they couldn't receive data from other.
Have you some appropriate solutions?
one thing else, I don't know the way to improve this method to Fotune Server can receive data from Fotune Client, Can we make alterations this method? or Must create other. Please help me!
void Server::sendFortune(){
QByteArray block;
char bufff[256];
QDataStream out(&block, QIODevice::WriteOnly);
out.setVersion(QDataStream::Qt_4_0);
out << (quint16)0;
out << fortunes.at(qrand() % fortunes.size());
out.device()->seek(0);
out << (quint16)(block.size() - sizeof(quint16));
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
connect(clientConnection, SIGNAL(disconnected()),
clientConnection, SLOT(deleteLater()));
clientConnection->write(block);
clientConnection->disconnectFromHost();
}
Thanks for your replies>
Bookmarks