QTcpServer and QTcpClient
Hi,
for an InterProcessCommunication between a OSX und Linux
I developed server- and clientprocesses on the Mac with QtCreator.
The client sends a question to the server. The server solves the problem
an sends the answer back to the client.
All works fine!
But when I starts the two processes outside the QtCreator, nothing works!
The server and client works correct ( checked with status-messages ),
but data are'nt swap.
As a test, i try it with QLocalServer and QLocalSocket. In this case all works fine.
I can start the applications outside QtCreator and the data will be changed.
But in the LAN ( OSX and Linux ) this could'nt work.
Thanks for solutions.
My english is'nt perfect, so I hope you understand what I wrote!
Happy Christmas GBunge
Re: QTcpServer and QTcpClient
There is really not enough information to provide any meaningful help :(
Can you verify that the QTcpServer's listen() works? I.e. does it return "true"?
Are you testing with both on the same machine?
Cheers,
_
Re: QTcpServer and QTcpClient
Hi,
first, both tests on the same machine! (Mac)
Start inside QtCreator all works!
Start outside:
The connection is established.
The server listen returns 'true'.
If I start the client without running the server, a statusmessage pops up "server not online".
Make it sense, when I post the code of the two applications?
And how can I do it?
GBunge
Re: QTcpServer and QTcpClient
You can attach a ZIP file containing the project.
Cheers,
_
Re: QTcpServer and QTcpClient
Hi anda_skoa,
the problem is fixed!
In the memberfunction 'void IPCServer::readData()'
Code:
void IPCServer::readData()
// Byte-Anzahl auslesen ++++++++++++++++++++++++++
if( anzahl == 0)
{ if( client->bytesAvailable() < (int)sizeof(quint16)) return;
in >> anzahl;
}
if( client->bytesAvailable() < anzahl) return;
// Socket auslesen +++++++++++++++++++++++++++++++
in >> data;
// Antwort berechnen +++++++++++++++++++++++++++++
compute( data );
// Antwort senden ++++++++++++++++++++++++++++++++
sendData();
anzahl = 0;
}
the Classvariable 'anzahl' are not 0.
Therefor the metode couldn't work.
I forgot to initialising this variable in the constructor.
But the mysterium:
inside QtCreator there is no consequence,
outside QtCreator the consequence is 'no datatransfer',
I don't understand this! But it runs!
Thanks for your time!
GBunge
Re: QTcpServer and QTcpClient
If you get different behavior in and outside of Creator then it means you are running two different binaries.
Re: QTcpServer and QTcpClient
If anzahl was not 0 because it was not properly initialized then it might have worked in creator just out of pure luck, i.e. the memory incidentally being 0 in that case.
Cheers,
_