Win32 -- socket set to "read watch" does NOT get notified
- From: Igor Chudov <ichudov Algebra Com>
- To: gtk-perl-list gnome org
- Subject: Win32 -- socket set to "read watch" does NOT get notified
- Date: Tue, 26 Jun 2007 13:35:55 -0500
We wrote a little system in perl that uses GTK2-Perl. It is a system
that connects to something via a socket, asynchronously, and then is
notified when data comes in and does something with the data.
To registed a perl Socket object for asynchronous data notifications,
we do
my $fh1 = Gtk2::Helper->add_watch ( $socket->fileno, 'in', \&socket_callback,
{
socket => $socket,
loop => $this,
engine => $engine,
}
);
It works great under Linux and we get notified when data comes in, read it, etc.
Under MS Windows, socket_callback is not called for data coming in, so
the program is worthless.
As a litle backgrounder here, Win32's socket API WinSock is highly
fucked up, so that a socket requires a Window Handle to get the window
notified about socket events. It is a stupid carryover from Windows
3.11 or some such junk. You have to attach a socket to a window.
That's the problem that most people encounter when they move a select
loop from Unix to Windows. If they forget to attach the socket to a
window, the program is not notified about asynchronous events.
I am afraid that this is the same problem. I looked at some source
code. The glib library has a function g_io_win32_prepare. This
function tries to tell what is the Source, and if it is a Socket, it
does WSAEventSelect. See here
http://msdn2.microsoft.com/en-us/library/ms741576.aspx
it is similar to WSAEventSelect. I think that calling it attaches the
socket to a Windows Handle properly.
Anyway. The issue might be that Gtk2::Helper, when it adds a watch,
calls g_io_add_watch. Which I am sure is the right thing. But it never
does g_io_win32_prepare. Hence the events are not posted to the
program.
There is no method to call g_io_win32_prepare separately.
Any thoughts on this. I am at the end of my rope, we want to use this
framework, but are very hampered by not being able to read from the
network.
I have a weird procmail setup at home, so, if you have something to
say, would be great if you at least Cc: it to me. I am going to set up
procmail for a separate mailbox for this mailing list.
Thanks guys and ladies, you did a great job.
i
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]