RE: programming practices with regard to gtk and networking




What I need to do is somehow create the connection when the button
is clicked and then pass the sockfd to the calling part of the
programming (main) so I can then use that in the calls to send().
What I really need is someone to point me in the right direction.

How many connections will you be making?  How long will these connections persist?  And what new signal 
connections will you be making after this connection has been made?

Sounds to me like you'd be better off creating an object that handles the connection.  The object would offer 
methods to create a connection, send and receive messages and what-not, and finally close the connection.

You could then create a new (un-connected) "connection" object, and pass a reference to that in the user_data 
of the button.  The button would then just have to trigger the "connect" method of the object.

If you want to avoid creating a whole GObject for it, you can just put together a struct with all the 
relevant bits and pieces, and call all your functions with a naming structure similar to what GTK uses.  
(Which is basically all an object is anyhow, until you start adding OOP features like inheritance, property 
introspection, etc.)


Fredderic

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!





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