How to do Asynchronous I/O in win32?
am 06.09.2007 06:41:43 von sonetHave any modules like http://www.summerblue.net/computing/libiocp/index.html
for win32-perl ?
Have any modules like http://www.summerblue.net/computing/libiocp/index.html
for win32-perl ?
Quoth "sonet"
> Have any modules like http://www.summerblue.net/computing/libiocp/index.html
> for win32-perl ?
If you want to use real Win32 overlapped IO, you can use the functions
in Win32API::File. You will need to closely refer to the MSDN
documentation for these, though: the interface is currently not very
friendly, and you will need to build your own OVERLAPPED structure using
pack.
I was about to suggest using POE, as that is the standard suggestion for
event loops, but it appears not to support operations on ordinary files
under Win32 (due to select(2) being deeply broken). If you only want to
monitor sockets, you should be able to use any of the select-based
systems: POE has its own, or you can use Event.pm.
If you are a C programmer, and you like the libiocp interface, you could
try your hand at wrapping it in an XS module. It doesn't look too hard:
you would need to write your own set of C callbacks to register, and
then have those callbacks call the Perl callbacks (if that makes sense
:) ). Start by reading perlxs, and you'll probably need to follow that
with perlcall. Or you could use Inline::C, though given that you'd still
have to have C-callbacks-calling-Perl-callbacks I doubt it would be much
easier.
Good luck: this is clearly an area where Perl's Win32 support needs
work, so I hope you can find something that does what you need.
Ben