perl6 web-app
TRANSCRIPT
Writing web application on Perl6
(In progress)2015.09.17 gotanda.pm
tokuhirom
MoarVM’s IO has an issue.
https://github.com/MoarVM/MoarVM/issues/165
Can’t pass fd between threads
orz
But we can call libc methods via NativeCall
First, call fork(2) via NativeCall
sub fork() returns Int is native { ... }
Easy.
2nd, call waitpid(2) via NativeCall
module private { our sub waitpid(Int $pid, CArray[int] $status, Int $options) returns Int is native { ... } }
sub waitpid(Int $pid, Int $options) is export { my $status = CArray[int].new; $status[0] = 0; my $ret_pid = private::waitpid($pid, $status, $options); return ($ret_pid, $status[0]); }
Easy! (Patches welcome…)
Then,
Let’s implement BSD sockets wrapper.
I don’t recommend to use NativeCall directly.
There’s too many C types/structs.
Too many wrapper types…
Write dll in C. And call it via NativeCall.
Raw::Socket
BSD socket wrapper for Perl6
Then, write httpd.
Support features
• parse request
• send response
• pre-fork
• shotgun - reload code
• Win32 support ← NEW!
Demo
soozy.fushihara.net #perl6
Thanks!