Skip Menu |

This queue is for tickets about the POE CPAN distribution.

Report information
The Basics
Id: 1773
Status: resolved
Priority: 0/
Queue: POE

People
Owner: RCAPUTO [...] cpan.org
Requestors: garrett [...] scriptpro.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



From: Garrett Goebel <garrett [...] scriptpro.com>
To: 'Rocco Caputo' <troc [...] netrus.net>, poe [...] perl.org
Cc: bug-POE [...] rt.cpan.org
Subject: RE: Win32: WSA_OVERLAPPED_IO and non-blocking connect()
Date: Thu, 7 Nov 2002 10:36:32 -0600
Nothing really new except more citations of potentially relevant documentation. New comments all the way at the bottom... From: Rocco Caputo [mailto:troc@netrus.net] Show quoted text
> On Wed, Nov 06, 2002 at 05:08:48PM -0600, Garrett Goebel wrote:
> > Rocco, > > > > I apologize for my ignorance in advanced. I've started > > re-reading "Network Programming with Perl". -Which I'd > > read once long ago, never used, and consequently have > > completely forgotten. > > > > I noticed your post to p5p on this issue back in August 2001: > > http://archive.develooper.com/perl5-porters@perl.org/msg62779.html > > > > Where you use ioctl to flip the socket to non-blocking mode > > (as stolen from POE::Wheel::SocketFactory). > > > > I also noticed an interesting article: > > INFO: Socket Overlapped I/O Versus Blocking/Non-blocking Mode > > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q181611 > > > > Where it says:
> > > Please note that once a socket is created, there is no way > > > to change the socket overlapped attribute. However, you can > > > call the setsockopt API with SO_OPENTYPE option on any socket > > > handles including an INVALID_SOCKET to change the overlapped > > > attributes for all successive socket calls in the same thread. > > > The default SO_OPENTYPE option value is 0, which sets the > > > overlapped attribute. All non-zero option values make the > > > socket synchronous and make it so that you cannot use a > > > completion function
> > > > So I'm wondering if there's an exposed mechanism in perl to set > > this attribute similar to how you used ioctl to set the FIONBIO > > attribute? I'm not sure what "all successive socket calls" > > means... but I'm curious if having set this attribute, followed > > by the FIONBIO call to ioctl... you might be able to get that > > non-blocking connect? > > > > Its probably just one of those "pie in the sky" ideas which > > ignorance allows one to think is possible...
> > It's an excellent lead and one I'll be pursuing once I get this NT > machine set up. You may be right about "pie in the sky". If > ActiveState is correct, the overlapped mode is required so that the > socket will behave like a filehandle in all other respects. > > It's a shame that overlapped mode can't be changed after the socket is > created. Otherwise I could treat the socket as non-overlapped for the > duration of the connect and then set it back to overlapping for I/O. > > I'm probably going to release 0.24 before getting to work on the > Windows issues again, if only because 0.24 is practically ready to go > now. > > Cc'd to bug-POE@rt.cpan.org for posterity.
It seems pretty clear that overlapped and non-blocking io should be orthogonal, but have been implemented otherwise... as MS Knowledgebook article Q181611 states: Show quoted text
> The socket overlapped I/O attribute is different from the > socket's blocking or non-blocking mode. Although the current > Winsock implementation requires overlapped I/O attribute for > non-blocking socket mode, they are conceptually independent > and their programming model is different too.
In Q189171, it indicates that this behaviour changed between Winsock 1.1 and Winsock 2.0, from a default of overlapped to non-overlapped. The other 2 references in MSDN show overlapped as the default. "socket" topic in the Windows Sockets: Platform SDK: Show quoted text
> The socket that is created will have the overlapped attribute > as a default. For Microsoft operating systems, the Microsoft- > specific socket option, SO_OPENTYPE, defined in Mswsock.h can > affect this default.
Q131623: Show quoted text
> By default, all socket handles are opened as overlapped > handles so that asynchronous I/O can be performed on them. > However, in many situations you may find it preferable to > have nonoverlapped (synchronous) socket handles. > > For example, only nonoverlapped handles can be used with the > C run-time libraries or used as standard I/O handles for a > process. Under Windows NT and Windows 95, the SO_OPENTYPE > socket option allows an application to open non-overlapped > socket handles.
So I assume problems like: Q179942 INFO: WSA_FLAG_OVERLAPPED Is Needed For Non-Blocking Sockets Exist because the assumption that a socket would default to overlapped io has been violated when that behaviour was changed... Which is probably why there doesn't appear to be a way to change the socket overlapped attribute. Implementation details which assumed overlapped io, and so provided means to turn it off. But which don't necessary garrauntee the reverse. -- Garrett Goebel IS Development Specialist ScriptPro Direct: 913.403.5261 5828 Reeds Road Main: 913.384.1008 Mission, KS 66202 Fax: 913.384.2180 www.scriptpro.com garrett@scriptpro.com