Re: win32 and glib, socket data inaccessible
- From: Marc Lehmann <gtk-perl schmorp de>
- To: gtk-perl-list gnome org
- Subject: Re: win32 and glib, socket data inaccessible
- Date: Fri, 1 Jul 2005 07:34:56 +0200
On Fri, Jul 01, 2005 at 07:13:29AM +0200, Marc Lehmann <gtk-perl schmorp de> wrote:
I'll do some research.
Couldn't sleep, so I did some research now instead of later. Indeed:
glib expects an os handle.
#ifdef USE_SOCKETS_AS_HANDLES
# define TO_SOCKET(x) _get_osfhandle(x)
#else
# define TO_SOCKET(x) (x)
#endif /* USE_SOCKETS_AS_HANDLES */
so whenever add_watch gets a socket, it must pass in
TO_SOCKET(perlfileno), while for normal files, it has to pass in just the
perlfileno.
Now, as it has to find out wether sth. is a socket or a file, it can also
call the appropriate function inside glib, so that fixes another bug
(socket filenos and file filenos can overlap in theory).
Digging some more, it seems one can distinguish between the two by:
io = GvIO(gv);
if (io && IoTYPE(io) == IoTYPE_SOCKET) {
Incidentally, this would require add_watch to be changed to accept a perl
filehandle, unless somebody can deduce the type of a perl fd.
Or maybe one can always call TO_SOCKET on _all_ perl filenos, and the
result of TO_SOCKET is always the correct handle to call with into glib. I
am not sure.
(Maybe both ways would work, from the code it seems that perl vis-a-vis
the runtime lib converts sockets into "unix fds". But as glib calls fstat
on the fd, I am not sure wether TO_SOCKET would return the right thing. It
ist most clean to actually call the correct glib function instead of
having it guess).
(And I might not try it out for some time).
(And I guess I was the only person trying to use Gtk2+sockets some years
ago where it didn't work, and I guess I am still he only one trying. I
think that's a good sign, actually).
(Damn, I tried very hard to avoid having to build perl modules for
activestate... it's sooo horrible and maybe I won't even succeed...).
interface? (Sorry if it's the latter case).
Not a problem known to me, at least.
Well... :)
The only hint of the GIOChannel API visible at the perl level is
Glib::IO::add_watch(). This was by design, because GIOChannel provides
Incidentally, native win32 perl changes the sysread into a recv anyways.
*sigh*
Good Night,
--
The choice of a
-----==- _GNU_
----==-- _ generation Marc Lehmann
---==---(_)__ __ ____ __ pcg goof com
--==---/ / _ \/ // /\ \/ / http://schmorp.de/
-=====/_/_//_/\_,_/ /_/\_\ XX11-RIPE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]