Re: Threads, sockets and windows

2006-08-09 Thread Tor Lillqvist
Vladimir writes: > Can I just use g_io_channel_unix_new(socket) to create GIOChannel for > windows socket ? Not reliably. The same small integer might be both a valid file descriptor and a socket, and there is no way for g_io_channel_unix_new() to know which one you mean. Use g_io_channel_win32

Re: Threads, sockets and windows

2006-08-09 Thread Vladimir
Hello, > If I recall correctly, one good rule of thumb is to read as much can > from a GIOChannel when you get the callback that it is readable, until > you get G_IO_STATUS_AGAIN. Can I just use g_io_channel_unix_new(socket) to create GIOChannel for windows socket ? The main problem in my progr

Re: Threads, sockets and windows

2006-08-08 Thread Anna
On Mon, Aug 07, 2006 at 09:44:06PM +0300, Vladimir wrote: > Hello, > > I'm trying to write two-threaded program: one thread for GUI and the other > for network. The network thread needs to poll network socket and to receive > messages from the GUI thread (such as commands to send something to netw

Re: Threads, sockets and windows

2006-08-08 Thread Tor Lillqvist
Armin Burgmeier writes: > A probably better approach would be to let glib poll your sockets via > creating GIOChannels and using g_io_add_watch to watch for events to > occur. Yep, and this then will in fact use the WSAEventSelect mechanism on Windows. (In GLib >= 2.8) Please note, though, tha

Re: Threads, sockets and windows

2006-08-08 Thread Frank Naumann
Hello! >> Under Window you can use select(). For myself I've written for Win32 a >> poll() function that internally use select() (so the code remains clean >> and portable). > (Whoops. I should have pressed reply to all. Sorry for the > inconvenience, Frank.) No problem. > The Windows select() f

Re: Threads, sockets and windows

2006-08-08 Thread Armin Burgmeier
> But on windows there is no poll() function. Of course I can use > g_async_queue, but doing so I can't poll queue and network socket > simultaneously. You can associate WSAEvents to your socket via WSAEventSelect and then wait for the events to become signaled using WSAWaitForMultipleObjects. Usin

Re: Threads, sockets and windows

2006-08-08 Thread Armin Burgmeier
> > But on windows there is no poll() function. Of course I can use > > g_async_queue, but doing so I can't poll queue and network socket > > simultaneously. > > Under Window you can use select(). For myself I've written for Win32 a > poll() function that internally use select() (so the code rema

Re: Threads, sockets and windows

2006-08-08 Thread Frank Naumann
Hello! > But on windows there is no poll() function. Of course I can use > g_async_queue, but doing so I can't poll queue and network socket > simultaneously. Under Window you can use select(). For myself I've written for Win32 a poll() function that internally use select() (so the code remains

Threads, sockets and windows

2006-08-08 Thread Vladimir
Hello, I'm trying to write two-threaded program: one thread for GUI and the other for network. The network thread needs to poll network socket and to receive messages from the GUI thread (such as commands to send something to network or to disconnect). I've used pipe for commands, so in the networ