problems with GIOChannel



Hello eveeryone

I had a problem with socket (actually with updating widget by the thread
responsible for receiving data from the socket), read about GIOChannel
and found out that it may help me to get rid of my problem..
It eliminates my "receiving thread" which is good since I have no more
problem with not updated GtkTextView.

I want to ask two questions about GIOChannel:

1) when I add the channel to event loop by g_io_channel_add_watch(),
channel's reference number becomes 2. It's ok, but when I close the
socket: g_io_channel_shutdown() and g_io_unref() the reference number is
1. How can I remove this GIOChannel from the main event loop (is there
anything like g_io_channel_remove_watch() ?) ?

2) when data is ready to be received (in a socket) my application
freezes. I debugged it and found out that it freezes in
g_io_channel_read_chars(). I pass an allocated buffer and length of the
buffer to this function and it tries to alocate an internal buffer, then
it reads data and finally freezes. When I set channel->use_buffer to
FALSE, everything works fine. My question is why "use_buffer" makes
g_io_channel_read_chars to freeze? And if that's intended behavior why
g_io_channel_init() sets user_buffer to TRUE by default?

Did any one have similiar problem?
I use GLib version 2.2.1

Setting use_buffer to FALSE solves my problem but I want to know why
this happens. I hope someone can explain.

Best regards
Pablo

------------------------------------
pawelp at mail dot softsystem dot pl






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