Re: GIOChannel on win32: g_io_add_watch problem




 Daniel,

 This is unrelated to the problem.. but anyhow, have you taken a look at Gnet?

 www.gnetlibrary.org -- It will save a lot of headaches like this one.

Harring

--- "Daniel K. O." <danielosmari yahoo com br> wrote:
Hello


I'm having some trouble using GIOChannels. This is the snippet:

---
gboolean foo(GIOChannel *source, GIOCondition cond, gpointer data)
{
        g_io_channel_write_chars(source, "FOO\n\r", 5, NULL, NULL);
        g_io_channel_flush(source, NULL);
        return FALSE;
}
gboolean foo_timmer(int sock) /* there's a g_timeout_add for calling 
this func every second */
{
        GIOChannel *channel;
        channel = g_io_channel_unix_new(sock);
        tag = g_io_add_watch(channel, G_IO_OUT, foo, NULL);
        g_io_channel_unref(channel);
        return TRUE;
}
---



This is actually a simplified code from a bigger program, to reproduces 
an odd behavior: every second, a new TCP and UDP socket is created (I'm 
watching it with TCPView). The sockets accumulate (a lot of them) until 
the program crashes.
Seems that the GIOChannel is never deallocated. If I add another 
g_io_channel_unref inside the "foof" function, my system crashes.

So, I'm asking if this is the correct way to use GIOChannels. Am I using 
the g_io_channel_unref in the right places? And please, don't tell me I 
shouldn't create a new GIOChannel every second, cause GDK do the same 
thing with gdk_input_add.... or did I misread the code?


I'm using Win 98 SE,
gcc version 3.2.3 (mingw special 20030504-1),
glib-2.2.3


Thanks in advance.


Daniel K. O.

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


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html



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