1
我只是做了自己的實現QTcpServer既可和超載incomingConnection
功能。我怎樣才能訪問的QThread在QTcpServer既可
void Server::incomingConnection(int handle) //Server inherits from QTcpServer
{
qDebug()<<"Server::incomingConnection"<<handle;
Thread *thread = new Thread(handle,this);
connect(thread,SIGNAL(finished()),this,SLOT(deleteLater()));
thread->start();
}
在線程我做以下事情:
void Thread::run()
{
qDebug() << m_socketDescriptor << "Starting Thread";
m_socket = new QTcpSocket();
if(!m_socket->setSocketDescriptor(m_socketDescriptor))
return;
connect(m_socket,SIGNAL(readyRead()),this,SLOT(readyRead()));
connect(m_socket,SIGNAL(disconnected()),this,SLOT(disconnected()));
qDebug() << m_socketDescriptor << "Client connected";
exec();
}
現在我已經一個多線程的服務器。
但我怎麼可以訪問連接的客戶端,並通過發送他們的數據。 gui?
預先感謝您!
問候
你跟蹤不知何故連接? –