Results 1 to 2 of 2

Thread: Server not reading

  1. #1
    Join Date
    Jan 2006
    Posts
    185
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Server not reading

    For some reason this server is not reading
    Qt Code:
    1. ClientThread::ClientThread(int socketDescriptor, QTextBrowser * textBrowser)
    2. {
    3. _socketDescriptor = socketDescriptor;
    4. _textBrowser = textBrowser;
    5. run();
    6. }
    7.  
    8.  
    9. void ClientThread::run()
    10. {
    11. dataIn = "";
    12. tcpSocket = new QTcpSocket();
    13. if(!tcpSocket->setSocketDescriptor(_socketDescriptor)){
    14. _textBrowser->append("Error in the connection");
    15. exit();
    16. }
    17. _textBrowser->append("Client successfully connected");
    18. connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readData()));
    19. exec();
    20. }
    21.  
    22.  
    23. void ClientThread::readData()
    24. {
    25. dataIn=(tcpSocket->readAll());
    26. _textBrowser->append("Hi");
    27. _textBrowser->append(dataIn);
    28. }
    To copy to clipboard, switch view to plain text mode 

    Suggestions !!!

  2. #2
    Join Date
    Aug 2006
    Location
    Switzerland
    Posts
    52
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Server not reading

    I'm not shure if calling run() creates a new thread. This method is just what the thread is doing when it's running. When you call start() the thread is created and it executes run() method.
    The Wheel weaves as the Wheel wills.

Similar Threads

  1. Replies: 6
    Last Post: 8th January 2007, 10:24
  2. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 14:43
  3. Sql Server cannot retrieve data from select
    By Atomino in forum Qt Programming
    Replies: 10
    Last Post: 7th September 2006, 16:37
  4. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15
  5. Reading from TCP Socket crashes program
    By OnionRingOfDoom in forum Qt Programming
    Replies: 26
    Last Post: 27th January 2006, 19:32

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.