Re: GTK and network socket programming




Micah Yoder <lyoder@cyberis.net> writes:

> Hi,
> 
> I'm attempting to write a networked game using GTK.  It's in its early
> stages, though I have most of the server (non-GTK) coded.
> 
> I'm somewhat new to both sockets and GTK, but it seems as though it
> would be difficult to get them to work together in the same program. 
> How can a program be waiting for a GTK event and listening on a socket
> at the same time?
> 
> Can someone point me to a resource on this?

Take a look at the gdk_input_add() function.

gint gdk_input_add	  (gint		     source,
			   GdkInputCondition condition,
			   GdkInputFunction  function,
			   gpointer	     data);

typedef enum
{
  GDK_INPUT_READ       = 1 << 0,
  GDK_INPUT_WRITE      = 1 << 1,
  GDK_INPUT_EXCEPTION  = 1 << 2
} GdkInputCondition;

This allows you to specify a function that will be called
any time a certain file descriptor becomes available for
reading or writing.

Regards,
                                        Owen



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