Re: Can I listen on a socket in a GTK application?

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

 



What Paul ment to say ;-), was that gtk as well as most gui toolkits
these days, are implementing a paradigm known as event-driven
programming, see
http://en.wikipedia.org/wiki/Event-driven_programming . The loop is
implemented by the glib main loop. gtk registers its callbacks to the
mainloop (button presses etc), but you may add additional callbacks,
e.g. from sockets. The mainloop just hangs there until something
happen that has been registered to it.

Paul is certainly right that you don't have to know the implementation
details. Just register your callbacks and trust that everything will
work.

Regards,
Dov

On 3/26/06, yinglcs2@xxxxxxxxx <yinglcs2@xxxxxxxxx> wrote:
> Thanks. But there is something I still don't quite
> understand.
>
> a GTK application has a main loop listen for any GTK
> signals (for example to handle the close window
> event), right?
> But now if I make it to listen to an socket, how can
> it listen but the socket and the GTK signals?
>
> Thank you for any advice.
>
>
> --- Dov Grobgeld <dov.grobgeld@xxxxxxxxx> wrote:
>
> > Hi,
> >
> > (I'm moving the discussion back to gtk-list as I
> > didn't actually mean
> > to send it private. Hope it is ok with you.)
> >
> > Regarding your question, yes, gtk_main() is really a
> > wrapper to
> > g_main_run(main_loop), so everything that is valid
> > for g_main_loop()
> > is valid for gtk_main() as well. Just set up your
> > gnet callback
> > handlers and then call gtk_main().
> >
> > Hope this helps.
> >
> > Regards,
> > Dov
> >
> >
> > On 3/25/06, yinglcs2@xxxxxxxxx <yinglcs2@xxxxxxxxx>
> > wrote:
> > > Dov,
> > >
> > > Thanks for your respond. I am interested in
> > knowing
> > > how you did that.
> > >
> > > I have read the example you suggest. But one thing
> > I
> > > am not sure is if I still call "gtk_main();"?
> > > And when does it call "gtk_main() now if I call
> > >   /* Start the main loop */
> > >   g_main_run(main_loop);
> > >
> > > from the gnet example?
> > >
> > > Thank you.
> > >
> > > --- Dov Grobgeld <dov.grobgeld@xxxxxxxxx> wrote:
> > >
> > > > It sure is. One of the easiest ways is to use
> > gnet.
> > > > Have a look at the
> > > > gnet-*/examples/echoserver-gserver.c program in
> > the
> > > > gnet sources that
> > > > shows you how to creates a server that
> > integrates
> > > > with the glib main
> > > > loop.
> > > >
> > > > I'm using exactly that approach for
> > > > remotecontrolling a gtk based
> > > > image viewer application by sending it tcp-ip
> > > > commands .
> > > >
> > > > Regards,
> > > > Dov
> > > >
> > > > On 3/22/06, yinglcs2@xxxxxxxxx
> > <yinglcs2@xxxxxxxxx>
> > > > wrote:
> > > > > In my GTK application, is it possible for it
> > to
> > > > listen
> > > > > on a socket (as a server)?
> > > > >
> > > > > Thank you.
> > > > >
> > > > >
> > __________________________________________________
> > > > > Do You Yahoo!?
> > > > > Tired of spam?  Yahoo! Mail has the best spam
> > > > protection around
> > > > > http://mail.yahoo.com
> > > > >
> > _______________________________________________
> > > > > 
> > > > > gtk-list@xxxxxxxxx
> > > > >
> > http://mail.gnome.org/mailman/listinfo/gtk-list
> > > > >
> > > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > > http://mail.yahoo.com
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux