Re: g_io_add_watch, g_io_channel_read stops working after sometime.



On Wed, 2007-04-18 at 04:39 -0700, Rehan wrote:

Hi, 

 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.... 

in summary function calls: 

->socket(AF_INET,SOCK_STREAM,0) 
->bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) 
->listen(sockfd,5) 
->accept(sockfd, (struct sockaddr *) &cli_addr, &clilen) 
->g_io_channel_unix_new (global_sock) 
->g_io_add_watch(listenonsocket, G_IO_IN | G_IO_PRI,read_request,&global_sock) 

Rehan,

What is "listenonsocket" ?  Why no "G_IO_HUP" ?   the above sequence is
correct; however the api values seem to be wrong and in the wrong order!
Post or include the real code.  

As an example, look at the code in this sample "sknet" for the following
url.
http://mysite.verizon.net/skoona/id1.html



James,


->g_io_channel_read(channel,&len,sizeof(len),&bytes_read); 

I hope somebody comes to my rescue its been now 3 days i am trying to solve
this problem but no success... 

Thanks in advance for all great coders.... 

Regards, 
RS.



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