LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-04-2011, 10:20 AM   #1
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Qt: Automated monitoring of different sockets for available data


nextPendingConnection () returns a new socket with respect to a new client.
This new QSocket is passed to the connect () function which connects it to a SLOT 'xyz' with SIGNAL 'readyRead()'.

Now in the SLOT 'xyz' how I am supposed to automate the monitoring of ALL connected sockets to see whether some data is available on them?

One pathetic way would be to run all the sockets through a for loop and check each one of them for the data.

Secondly, I read up on QSocketNotifier() here: http://doc.qt.nokia.com/4.7-snapshot...SocketNotifier

But I am not sure if that is the correct thing, please guide.

Last edited by Aquarius_Girl; 02-04-2011 at 10:23 AM.
 
Old 02-04-2011, 11:20 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I'm not well acquainted with Qt, but reading between the lines, it sounds like you are setting up various connections with signal handlers to handle the incoming data. This is a method to avoid the problem of 'monitoring of ALL connected sockets to see whether some data is available on them'. It sounds like you are inventing a problem which has already been avoided.

--- rod.
 
Old 02-04-2011, 07:03 PM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Thanks for replying, but somewhere I have to call the read function w.r.t the socket on which data is available, que is the read func. should be called for which socket if there are 10 of them?
 
Old 02-06-2011, 02:55 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731

Original Poster
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
SOLUTION:

http://doc.qt.nokia.com/4.7-snapshot/qsignalmapper.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sending binary data through sockets in C Carlos2313 Programming 1 11-29-2010 05:47 AM
C sockets loosing data? greeklegend Programming 8 01-10-2008 04:40 PM
Sockets and Binary data oulevon Programming 3 04-06-2006 04:35 AM
sockets dont ever send data alaios Programming 1 09-21-2005 06:59 PM
Can't figure out how to be listening for data all the time with C sockets Eddie101 Programming 2 03-25-2005 10:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration