Re: win32 and glib, socket data inaccessible




Marc Lehmann said:

I am trying to port a gtk2-perl program to windows (in theory an easy
task).

However, it's using sockets, and the only way to use them in a nonblocking
way (under Gtk2) seems to be to use glib watchers. Now, the problem is
that, when my callback gets called, glib has already read the data from
the filehandle, and there doesn't seem to be support for giochannels in
the Glib module, so there is no way to actually get the data.

Have you tried recv() instead of <> or sysread?  giochannel.h says "Contrary
to IO channels for file descriptors (on *Win32), you can use normal recv() or
recvfrom() on sockets even if GLib is polling them," and
g_io_channel_unix_new() on win32 calls g_io_channel_win32_new_socket() when it
determines that the fd is actually a socket.



Is this a known problem or did I just miss the giochannel
interface? (Sorry if it's the latter case).

Not a problem known to me, at least.

The only hint of the GIOChannel API visible at the perl level is
Glib::IO::add_watch().  This was by design, because GIOChannel provides
functionality normally provided by native perl file handles, and we made a
conscious effort not to duplicate these things.  Personally, i had no idea
that sockets behaved that way on win32.

So, er, it's probably broken.


-- 
muppet <scott at asofyet dot org>




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