NAME
Hypersonic::Ops - Low-level JIT-compiled ops for Hypersonic
SYNOPSIS
use Hypersonic::Ops;
my $listen_fd = Hypersonic::Ops::create_listen_socket(8080);
my $loop_fd = Hypersonic::Ops::create_event_loop($listen_fd);
while (1) {
my $events = Hypersonic::Ops::ev_poll($loop_fd, 1000);
for my $event (@$events) {
my ($fd, $flags) = @$event;
# Handle event...
}
}
DESCRIPTION
This module provides the low-level JIT-compiled operations for Hypersonic. It automatically compiles platform-specific C code on first use.
FUNCTIONS
create_listen_socket($port)
Create a non-blocking listening socket on the given port.
create_event_loop($listen_fd)
Create an epoll (Linux) or kqueue (macOS/BSD) event loop.
event_add($loop_fd, $fd)
Add a file descriptor to the event loop.
event_del($loop_fd, $fd)
Remove a file descriptor from the event loop.
ev_poll($loop_fd, $timeout_ms)
Wait for events. Returns an arrayref of [$fd, $flags] pairs.
http_accept($listen_fd)
Accept a new connection. Returns client fd or -1.
http_recv($fd)
Receive and parse an HTTP request. Returns [method, path, body, keep_alive, fd].
http_send($fd, $body, $content_type)
Send an HTTP response with the given body.
http_send_404($fd)
Send a 404 Not Found response.