GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Nov 21, 2014 2:28 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: gui for linux sockets
PostPosted: Wed Mar 07, 2012 2:12 am 
Offline
Familiar Face

Joined: Mon Mar 05, 2012 11:55 pm
Posts: 12
So I've been working with sockets in C for quite some time now and would like to make a GUI for a client and server. I use Linux, not windows. Does anyone know of a tutorial or resources for what I'm trying to accomplish?


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Wed Mar 07, 2012 8:17 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 776
Location: UK
Hi,

This is a very broad question and there is no short answer (or one that I am allowed to fit here :).

There and links to many tutorials here http://www.gtkforums.com/viewtopic.php?f=3&t=988

Since you are using sockets you can monitor them using GLib see http://developer.gnome.org/glib/stable/glib-IO-Channels.html

Note like most GUI tool kits GTK+ is event based and if your original code is not event based then you will need to do some work to make it event based or use threads.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Wed Mar 07, 2012 8:07 pm 
Offline
Familiar Face

Joined: Mon Mar 05, 2012 11:55 pm
Posts: 12
Yeah my select server is not event driven. Its written in C. Do all GUI toolkits need event driven code? Maybe pythons PyQt GUI library? What I'm looking to do is take my code as is and add a GUI. The language is not an issue. Any ideas?


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Wed Mar 07, 2012 9:01 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 776
Location: UK
I don't think that I have a GUI tool kit that is not event based. Even QT, wxWidgets, MS Window, MacOS is event based.

You have two options to integrate your socket code with a GUI.

- Re-write sections of you socket code so that it fits in better with an event based system. If your current code uses select() or poll() or does something similar then they are starting points to place events.

- Have two threads. Thread one has the GUI code and thread two has the socket code. the threads then communicate the information needed. Unless you have previous experience of threads I would avoid this solution as it can be full of pit falls.

How complex is your socket code?

_________________
E.


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Wed Mar 07, 2012 10:28 pm 
Offline
Familiar Face

Joined: Mon Mar 05, 2012 11:55 pm
Posts: 12
I didn't think this was going to be this complicated. Is there a GTK library especially for sockets on Linux? And my sockets are basic. I have the basic synchronous client and server. A synchronous chat. I haven't incorporated the select function "yet", because it is a daunting task and I didn't know where I stood with the GUI. I didn't wanna have to change/switch everything around.


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Fri Mar 09, 2012 7:52 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 776
Location: UK
You can carry on using the same socket code with GTK+, and use the socket file descriptor to monitor if there is any data arriving, disconnection etc. within GTK+.

Also GTK+ has a library called GIO that can also handle socket coding in an object orientated way and offers additional support for other things you may need such as TLS (SSL) support if you want to add a secure layer. It is also a portability layer, so if you want to port to another system then this should make things simpler.

Since this is probably your first GUI application, you should really read the documentation and tutorials first. Tadej has produced some very tutorials at http://blog.borovsak.si/

I would suggest designing your GUI using Glade. It is an application where you can place your widgets in your windows giving them names, and save the information as an XML file. This can then be recalled in your application to display your windows and if you need to recall individual widgets by name. This should ease some of the learning needed and allow some flexibility in the design. With GTK+ you can choose many languages or use the native C API.

_________________
E.


Top
 Profile  
 
 Post subject: Re: gui for linux sockets
PostPosted: Wed Mar 21, 2012 2:07 pm 
Offline
GTK+ Guru

Joined: Sun Jan 17, 2010 6:48 pm
Posts: 102
Try Gnocl.

https://sites.google.com/site/gnocltclgtk/gnocl-user-documentation/commands/gnocl-socket

WJG

_________________
"If you don't stand for something, then you'll fall for anything."


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group