Re: gthreads and file operations



Let me explain the entire scenario.

I need to be listening to a socket for data from an external program. I do
this using an infinite loop. Once i get the data, i call a function and
after it returns I go back into infinite loop again.
While all this is happening I also need to listen to some signals (libwnck
signals, which work using the gtk_main() loop). Since gtk_main() blocks, I
created a new thread for the infinite loop.

I got one idea now. I created a separate thread just to listen to a socket
(while the other thread is listening for signals). Is it possible to listen
to the socket through the main event loop? If so, please let me know how
(possibly with an example). I can then safely remove the thread.


On Wed, Apr 14, 2010 at 3:40 AM, Chris Vine <chris cvine freeserve co uk>wrote:

On Wed, 14 Apr 2010 00:13:38 +0530
Nischal Rao <rao nischal gmail com> wrote:

is there any way to listen to signals without calling gtk_main()
(which never returns) ? If so, then i ll be able to get rid of
threads(happily!!).... I am new to glib threads and gnome signals.. i
have just been following examples that i found on the net.

Of course gtk_main() blocks, as it starts the main program event loop.
(You end the loop in order to terminate the program by calling
gtk_main_quit().)

Are you saying that you are using some external library which has its
own main loop?  If not, I don't understand your problem.  If you are
using such an external library, how are you interfacing (or trying to
interface) between the two?

Chris





-- 
regards,
Nischal E Rao
blogs.sun.com/nischal

Join RVCE OSUM at http://osum.sun.com/group/rvceosum



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]