PDA

View Full Version : Socket on a Thread



^NyAw^
7th May 2008, 10:33
Hi,

Can I create a socket on the main thread and move it then to another Thread using "moveToThread"?
I need the socket to recive the "readyRead" signal into the Thread.

Thanks,

^NyAw^
7th May 2008, 16:54
Hi,

My server run method:


void Thread::run()
{
if (!m_qSocket.setSocketDescriptor(m_iSocketDescripto r))
{
emit error(m_qSocket.error());
return;
}
bool bC = connect(&m_qSocket,SIGNAL(readyRead()),this,SLOT(readData() ));
exec();
}



If I don't call "exec()" the application crash because can't recive signals...
The "exec()" method is called to let the Thread recive signals.

"bC" returns true, but "readData()" is never called.
The client is sending one single char and then calling flush to ensure that is sended without any wait.


Thanks,

^NyAw^
7th May 2008, 16:56
Hi,

Sorry, it's working.