g_io_add_watch, g_io_channel_read stops working after sometime.
I am trying to write a program based on client-server architecture. I need only one client connection hence i am first listening to client then accept() is called. after accept() i call g_io_channel_unix_new () and then g_io_add_watch() and later in the function i use g_io_channel_read to read data from the channel.
Everything works fine till 4-5 requests from the client. Later the server simply stops listening to client. I have tried tcpdump on server side and i do recieve the TCP packet from the client. So it means there is some bug at server side. I am not sure if i have done something wrong or some bug in core library...
I am confused as the code works for 4-5 request and then simply starts ignoring the client messages. Is g_io_add_watch ignoring the incoming signals?? thats what i can detect from my gdb tracing.... there is no invocation of my function even if i recieve a packet on server side from the client....
- does your read_request() callback return TRUE whenever called? (or
rather: make sure it returns something in the first place)
- you should probably also watch for G_IO_HUP and G_IO_ERROR
- there are a bunch of libraries that provide higher-level abstractions
for this stuff based on GLib, such as GNet or libgnetwork (just FYI,
there's nothing wrong in principle with doing things directly).