hi everybody
ı am prepairing a client programme which takes data from server.how can ı take data from server.
hi everybody
ı am prepairing a client programme which takes data from server.how can ı take data from server.
Which kind of server do you have?
A camel can go 14 days without drink,
I can't!!!
Hi again,
I am writing a socket programme and i send data to my server.
Qt Code:
bool TcpClient::connectToServer() { if(!isConnectionOpen()) { tcpSocket->connectToHost(_serverAddress,_serverPort); } return true; } { if(!isConnectionOpen()) { connectToServer(); } tcpSocket->write((sendMsg+"\n").toAscii().data()); return "OK"; }To copy to clipboard, switch view to plain text mode
This function is return OK. I want to return response from server. For example;
My send data : Hello
Server Response : blablabla
this function's response : blablabla
How can I return response from server. I use TCP-IP protocol.
the better solution is use the signal/slot mechanism connecting the QAbstractSocket::readyRead() signal with one custom slot.
If you want use a single method that sends and receives data you must use code like:
Qt Code:
tcpSocket->write((sendMsg+"\n").toAscii().data()); bool ready = false; while (!ready) { // Wait for data received ready = tcpSocket->waitForReadyRead(); // Check if you can read a line \n terminated ready &= tcpSocket->canReadLine(); } return result;To copy to clipboard, switch view to plain text mode
A camel can go 14 days without drink,
I can't!!!
electronicboy (30th October 2009)
Bookmarks