Results 1 to 5 of 5

Thread: QLocalSocket, QThread and Signals

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Posts
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default QLocalSocket, QThread and Signals

    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

    Qt Code:
    1. Server::Server(QString servername, QObject *parent)
    2. : QObject(parent), m_clients(NULL)
    3. {
    4. m_server = new QLocalServer(this);
    5.  
    6. if (!m_server->listen(servername)) {
    7. qDebug() << "Not able to start the Server";
    8. }
    9.  
    10. connect(m_server, SIGNAL(newConnection()), this, SLOT(socket_new_connection()));
    11. }
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. void Server::socket_new_connection()
    2. {
    3. 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?
    Last edited by StarShaper; 9th January 2012 at 21:22.

Similar Threads

  1. qThread and Unix Signals
    By peterjb31 in forum Qt Programming
    Replies: 1
    Last Post: 7th April 2011, 11:24
  2. Signals not working in a QThread
    By curreli in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2010, 16:04
  3. QThread SIGNALS
    By Max123 in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2010, 13:17
  4. QThread and signals
    By bunjee in forum Qt Programming
    Replies: 8
    Last Post: 28th March 2008, 02:44
  5. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.