On Wed, Aug 18, 2004 at 02:51:06PM -0700, Stas Bekman wrote:
> Glenn Strauss wrote:
> >>>This is what we'd need bound to the Perl API:
> >>>
> >>>apr_os_sock_t fd;
> >>>apr_os_sock_get((apr_os_sock_t *) &fd, (apr_socket_t *) client_socket);
> >>>
> >>>On Unix-type platforms, apr_os_sock_t is an int -- the file descriptor,
> >>>which you can use with select() or IO::Select() or anything you
> >>>like in Perl to poll the descriptor:
> >>
> >>and what do you do with socket fd to get it to work with IO::Select?
> >
> >
> >Perl's equivalent of fdopen():
> >  open($FH, "<&=$fd")
> >and then use $FH
> 
> I guess that could work.
> 
> but I'm not sure how could we write a perl glue for apr_os_sock_get. How 
> will you handle apr_os_sock_t? You can't force it into int, can you?
> 
> >>>$rin = '';
> >>>vec($rin, $fd) = 1;  ## $fd directly instead of fileno(STDIN) or 
> >>>fileno($FH)
> >>>...
> >>>$nfound = select($rout=$rin, undef, undef, $timeout);
> >>>
> >>>
> >>>(On other platforms, like Windows, I don't know what apr_os_sock_t is;
> >>>check the headers files. :)
> >>
> >>I'd rather not expose OS specific bits if they won't work with all perl 
> >>modules. APR provides the API that should (hopefully) work on all 
> >>platforms, so why not use that?
> >
> >
> >I'm not a Windows programmer, but in the case of sockets, it looks like
> >it might be an int (file descriptor) on Windows, too.  We're talking
> >Berkeley sockets on both platforms, right?  Whatever socket() returns.

I was wrong.  apr_os_sock_t is a (SOCKET) on Win32, not an (int).

> why then APR went through the pain of abstracting this interface?

Turns out to be the obvious answer: because Windows does it differently
from everyone else.  Whether that is better or worse depends on the
situation, but the pain in writing cross-platform code still riles me,
not to mention how many 10's of clicks (hundreds?) it took me to navigate
the MSDN morass of documentation to find the following:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemNetSocketsSocketPropertiesTopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetsocketssocketclasshandletopic.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemintptrclasstopic.asp

The Socket.Handle property is what I think is needed so that
APR::OS::sock_get() can be made to work on Windows, too.
mpxs_APR__OS_sock_get() will need to special-case Windows platforms
and pull the Handle property.  I hope that works.  Any Windows
programmers out there?


Cheers,
Glenn

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to