Hi,
I am writing a server with QLocalSocket. I'm experienced with C# and now I have some questions about Qt. If I write a QLocalServer with
{
m_server = new QLocalServer(this);
if (!m_server->listen(servername)) {
qDebug() << "Not able to start the Server";
}
connect(m_server, SIGNAL(newConnection()), this, SLOT(socket_new_connection()));
}
Server::Server(QString servername, QObject *parent)
: QObject(parent), m_clients(NULL)
{
m_server = new QLocalServer(this);
if (!m_server->listen(servername)) {
qDebug() << "Not able to start the Server";
}
connect(m_server, SIGNAL(newConnection()), this, SLOT(socket_new_connection()));
}
To copy to clipboard, switch view to plain text mode
and
void Server::socket_new_connection()
{
QLocalSocket *clientConnection = m_server->nextPendingConnection();
void Server::socket_new_connection()
{
QLocalSocket *clientConnection = m_server->nextPendingConnection();
To copy to clipboard, switch view to plain text mode
What about socket_new_connection()? The signal is emitted every time a new connection is available. There are a lot of signals available in QLocalServer and QLocalSocket, but if the network is busy, my UI will not respond, right?
I would like to call socket_new_connection() in a seperate thread. In C# you can write a BackgroundWorker, which starts listening in a seperate Thread.
How would I pass a new Connection to an seperate Thread in Qt?
Maybe it's better to create a Worker Thread (inherited from QThread) for every socket connection?
Bookmarks