GUI with socket question!



This is a question about using sockets with gui library.

As I use gtk, so I post the question to here, if I am wrong, tell me please.

When I am tryingto use gtk wring a small apps, I find the question,
in main, the program will run to 'gtk_main()' and then, suspend, waiting for events, right??

If I have initialize a sock, and want to be notify if something is available within the socket, how can I do.

As usualy, I create sock, binding it, and then wait with listen (). But in this way, the program will never 
reach the line gtk_main().

I have think about an idea, but it just don't work, and I don't understand, 
it should be something like this.

sock ()
bind ()
fcntl () // set to non-blocking
fcntl () // set to sigio emit
sigaction // bind the sigio with an signal handler
gtk_main()

The idea is setting the socket to non-blocking and SETSIG so that, whenever the socket is available, SIGIO is 
emitted.
I use sigaction to set the signal handler for the SIGIO.

But it seems don't work.

BTW, does everyone has try to use this method.
If I have anything wrong with this, what's my fault??
And any other solution to this??


Zenith



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