class TestCase::Sys::Ioctl {
use Sys::Socket;
use Sys::Socket::Constant as SOCKET;
use Sys::Socket::Sockaddr;
use Sys::Socket::Sockaddr::In;
use Sys::Process;
use Sys::IO::Constant as IO;
use Sys::Ioctl;
use Sys::Ioctl::Constant as IOCTL;
use Sys::OS;
use Sys;
use Fn;
static method ioctl : int () {
# Socket
my $socket = Sys::Socket->socket(SOCKET->AF_INET, SOCKET->SOCK_STREAM, 0);
unless ($socket> 0) {
return 0;
}
Fn->defer([$socket : int] method :void () {
Sys::Socket->close($socket);
});
my $value_ref = [1];
my $status_ioctl = 0;
eval { $status_ioctl = Sys->ioctl($socket, IOCTL->FIONBIO, $value_ref); };
if (Sys::OS->is_windows) {
unless ($status_ioctl == 0) {
return 0;
}
}
else {
if ($@) {
warn "[Test Output]$@";
}
else {
unless ($status_ioctl == 0) {
return 0;
}
}
}
return 1;
}
}