Re: [gnet] Gnet-2.0.7 and win32



On Thursday 10 March 2005 20:21, Albert Veli wrote:

Hi,

> A much nicer way is to use g_io_add_watch() to register a
> callback routine that is automatically called when data comes
> in from the network. The problem is that I could not get
> this to work on win32 with gnet_tcp_socket_connect_async()
> (connection works but the callback is never called...).
>
> After banging my head frenetically to the wall for two days
> I found that if the connection is started with gnet_tcp_socket_new()
> instead, then g_io_add_watch() works, even on win32. And CPU usage is
> normal. Strange indeed.

I found that the GLib main loop/main context doesn't get going properly 
sometimes when writing GLib-only code for testing purposes. Adding something 
like:

static gboolean dummy_cb (gpointer baz) { return TRUE; } 

and then doing 

 g_timeout_add (500, dummy_cb, NULL);

usually does the trick for me. Not sure if the problem you're experiencing is 
really the same though.


>    (snip code)
> Then in the callback I use
> gnet_io_channel_readline_strdup() to read lines.
>
> The downside is that gnet_tcp_socket_new() blocks while connecting.
> But it's worth it ;-)

Is there a reason why you're not using GConn instead? GConn is much more 
convenient to use for asynchronous TCP connections.

Cheers
 -Tim




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