Watching a socket with g_io_add_watch(): works only first time



Hi folks,
I have a problem using g_io_add_watch on my socket. I want the function to be called when there is data 
waiting to be read, so I use the following calls:

iochan = g_io_channel_unix_new(sock_in);
g_io_add_watch(iochan, G_IO_IN | G_IO_PRI, read_input, (gpointer)sock_in);

send_a_message_to_socket(); /* peer answer to this */
gtk_main();


In read_input() I simply read 10 chars from the socket, using the glibc function recv(). This is just for 
debugging, I'd like to use g_io_channel_readline(), but that didn't work either.

Well, read_input() is only called once, although there is still data on the socket that needs to be read :(

So I guess I didn't set up the watch handler correctly, but I can't see what's wrong. I also tried 
referencing the GIOChannel in read_input so it doesn't get deleted, but it didn't help either.

What am I doing wrong?

Thanks in advance,
Tilman

-- 
Get GKrellM Newsticker @ http://gk-newsticker.sourceforge.net



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