NAME
Hypersonic::Event::Select - select() event backend (universal)
SYNOPSIS
use Hypersonic::Event;
my $backend = Hypersonic::Event->backend('select');
# $backend is 'Hypersonic::Event::Select'
DESCRIPTION
Hypersonic::Event::Select is the select()-based event backend for Hypersonic. It provides universal compatibility across all platforms including Windows, making it the fallback of last resort.
select() is the oldest and most portable event notification mechanism, but also the slowest due to O(n) scanning and FD_SETSIZE limitations.
METHODS
name
my $name = Hypersonic::Event::Select->name; # 'select'
Returns the backend name.
available
if (Hypersonic::Event::Select->available) { ... }
Always returns true - select() is available on all systems.
includes
Returns the C #include directives needed for select. On Windows, includes winsock2.h; on Unix, includes sys/select.h.
defines
Returns the C #define directives for select configuration, including FD_SETSIZE.
event_struct
my $struct = Hypersonic::Event::Select->event_struct; # 'fd_set'
Returns 'fd_set' (note: not used as an array like other backends).
extra_ldflags
my $flags = Hypersonic::Event::Select->extra_ldflags;
Returns '-lws2_32' on Windows, empty string otherwise.
gen_create($builder, $listen_fd_var)
Generates C code to initialize the master fd_set and add the listen socket. On Windows, also generates WSAStartup() call.
gen_add($builder, $loop_var, $fd_var)
Generates C code to add a file descriptor to the master fd_set and update max_fd.
gen_del($builder, $loop_var, $fd_var)
Generates C code to remove a file descriptor from the master fd_set.
gen_wait($builder, $loop_var, $events_var, $count_var, $timeout_var)
Generates C code to copy the master fd_set (select modifies it) and call select() with a timeout.
gen_get_fd($builder, $events_var, $index_var, $fd_var)
Generates C code to check FD_ISSET for each potential fd, skipping those without events.
gen_cleanup($builder)
Generates C code for cleanup. On Windows, calls WSACleanup().
LIMITATIONS
FD_SETSIZE limit (typically 1024 on Unix, 64 on Windows)
O(n) scanning of all file descriptors on each call
Must copy fd_set on each iteration (select modifies it)
Slower than poll(), epoll, or kqueue
WINDOWS SUPPORT
On Windows, this backend uses Winsock2 (ws2_32.lib). It automatically calls WSAStartup() during initialization and WSACleanup() during shutdown.
WHEN TO USE
Windows compatibility is required
Very old Unix systems without poll()
Testing on systems where other backends fail
Low-concurrency scenarios (< 100 connections)
AVAILABILITY
All systems: Linux, macOS, BSD, Windows, Solaris, AIX, HP-UX, etc.
SEE ALSO
Hypersonic::Event, Hypersonic::Event::Role, Hypersonic::Event::Poll
AUTHOR
LNATION <email@lnation.org>
LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.