Re: is there any example for "GIOChannel "?



why gtk_input_add ?

this works fine too:

int main(void) {
/*
...
*/

    channel = g_io_channel_unix_new(file_descriptor);

    g_io_add_watch(channel,
                G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_PRI
                /* or whatever fance flags you want */,
                function_pointer, user_data);


    g_main_loop_run(main_loop);
    return 0;
}


Cheers
        -Tristan

ginxd btopenworld com wrote:

Yes.  But first are you sure you need this for the right reason?  If you are intending on writing to a file 
(say for a log), its fine, but if you want to monitor read/write on a socket, you should use 
gtk_input_add().

Example:

  GIOChannel *channel;

  channel = g_io_channel_new_file(filename,"a+",NULL);

  if(channel == NULL)
    {
      g_error("failed to create new file:'%s' (channel) for log",filename);
      return FALSE;
    }

  g_io_channel_write_chars(channel,
                           message,
                           -1,
                           &bytes,
                           NULL);

  /* close file */
  g_io_channel_shutdown(channel,TRUE,NULL);

 from:    "chen.shengqi" <chen shengqi connet com tw>
 date:    Wed, 18 Sep 2002 08:44:57
 to:      gtk-app-devel-list gnome org
 subject: Re: is there any example for "GIOChannel "?


Regards,

Martyn
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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