Re: g_io_channel usage



You have to return with a TRUE-Value from the read-function. When you return 
with a FALSE-Value the callback function will be unregistered.

Hello everyone,

I encountered following problem using g_io_channel (Glib 2.0).
I was interested how the new API functions worksand wrote a little
example app. It contains only a gtk_entry, which you can write text to.
The text is sent to the receiver and printed with g_print().

It looks like this:

Server:
1, create server socket
2, accept client -> get socket
3, close server socket
4, continue with <Together>

Client:
1, create socket
2, connect with server
3, continue with <Together>

<Together>
1, create g_io_channel (g_io_channel_unix_new())
2, do not use buffered channel (g_io_channel_set_buffered())
3, do not use encoding (g_io_channel_set_encoding(chan,NULL))
3, register function for G_IO_IN condition (g_io_add_watch())
4, register function for G_IO_HUP condition
5, register other function for text entry etc...
6, run gtk_main

The problem is, that when I write a text to the entry, it is corretly
sent to the other side only for the first time. Doing the same once again
results text being correctly sent, but not comming to the receiver
(G_IO_IN condition is not valid). When I try to send data in reversed
direction, it also works only once. Did anyone met this?

When I was thinking about it I came to the select() call - it also has
some decriptors registered and after succesfull call they can be
verified etc. But they are also removed from the set and the set mut be
refreshed. I tried the same i this case... After reading data from
channel I use g_io_add_watch() again. It seems to work but.. is it
correct?

If anyone can help, I will be very thankfull. I also can pass my code to
the interested. Also any properly working C code would be heplful.
Thank you in advance.
Michal
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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