Re: File Descriptor Input



in addition to points made by others:
>/**** Ok, I have now revised it as follows ***/
>
>void input_callback( gpointer          data,
>                     gint              source, 
>                     GdkInputCondition condition )
>{
>  gchar *mesg;
>  mesg =data;
>  g_print("Got something.\n");
>}

this is still not the correct function prototype. it doesn't return a
value. moreover, i think you misunderstand what "data" is. its not the
data that is available to read. its the pointer you supplied in
gdk_input_add(). its your function's job to read the data from the
source. the "data" argument is just there in case it needs help
(e.g. some kind of additional information needed to read the data; not
normally necessary for simple i/o based on file descriptors). a
typical handler would look something like:

  int input_callback (gpointer data, gint source, GdkInputCondition cond)
  {
     char buf[SOME_SIZE];
     int call_again = TRUE;

     switch (cond) {
     case GDK_INPUT_READ:
           read (source, buf, SOME_SIZE);
           ... do something ...
	   break;

     case GDK_INPUT_EXCEPTION:
           ... do something ...
	   call_again = FALSE;
	   break;
     }

     return call_again;
  }

>> you can't do this. if you don't read the data, then
>> your function will
>> be called again immediately, because there is still
>> data to be read.
>
>I wish, it is called again and again :-)
>My problem is that it is not being called at all :-(

if you want it called again and again, the least you have to do is to
make it return TRUE.



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