socket and gtk problem, help!




Hi,all, I am writing a server program which listen and process client's request from other computer on LAN. I build server's GUI with gtk and wrote a piece of code to listen socket request as follow:

....

BuildGUI();


do{

int newsockd=accept(sockd,(struct sockaddr *)&client_addr,&sin_size);

if£¨newsockd!=-1£©

 DoSomething();

else

 continue;

}while(1);

....


there, gtk_main(); was put in BuildGUI. The program suspend when it goes to gtk_main(), so the do-while loop does not take effect .I know that gtk_main() raise a message loop and do-while is another loop . How can I make them work together? MultiThread program maybe a way to go and I tried but failed when i put some gtk-about code in DoSomething(). How should I do then?


Help me ,thanks!


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