Name
SPVM::IO::Socket - Socket Communications
Usage
use IO::Socket;
use Sys::Socket::Constant as SOCKET;
# Create a new AF_INET socket
my $io_socket= IO::Socket->new({Domain => SOCKET->AF_INET});
# Create a new AF_INET6 socket
my $io_socket= IO::Socket->new({Domain => SOCKET->AF_INET6});
# Create a new AF_UNIX socket
my $io_socket= IO::Socket->new({Domain => SOCKET->AF_UNIX});
Description
SPVM::IO::Socket provides socket communications.
Parent Class
Fields
timeout
has timeout : protected ro int;
sockdomain
has sockdomain : protected ro int;
socktype
has socktype : protected ro int;
protocol
has protocol : protected ro int;
peername
has peername : protected ro Sys::Socket::Sockaddr;
See also Sys::Socket::Sockaddr.
fd
has fd : protected int;
listen_backlog
has listen_backlog : protected int;
Class Methods
new
static method new : IO::Socket ($options : object[] = undef);
new Options
Timeout : Int
Domain : Int
Type : Int
Blocking : Int
Listen : Int
See also SPVM::Sys::Socket::Constant.
Instance Methods
new_instance
method new_instance : IO::Socket ($options : object[] = undef);
DESTROY
method DESTROY : void ();
init
protected method init : void ($options : object[] = undef);
connect
method connect : int ($address : Sys::Socket::Sockaddr);
See also Sys::Socket::Sockaddr.
recv
method recv : int ($buffer : mutable string, $length : int = -1, $flags : int = 0);
send
method send : int ($buffer : string, $flags : int = 0, $to : Sys::Socket::Sockaddr = undef);
See also Sys::Socket::Sockaddr.
close
method close : int ();
fileno
method fileno : int (); return $self->{fd}; }
opened
method opened : int ();
listen
method listen : int ($queue : int = 5);
bind
method bind : int ($address : Sys::Socket::Sockaddr);
See also Sys::Socket::Sockaddr.
sockname
method sockname : Sys::Socket::Sockaddr ();
See also Sys::Socket::Sockaddr.
shutdown
method shutdown : int ($sockfd : int, $how : int);
atmark
method atmark : int ();
setsockopt
method setsockopt : int ($level : int, $optname : int, $optval : int);
getsockopt
method getsockopt : int ($level : int, $optname : int);
connected
method connected : Sys::Socket::Sockaddr ();
See also Sys::Socket::Sockaddr.
socket
method socket : int ($domain : int, $type : int, $protocol : int = 0);
socketpair
method socketpair : int[] ($domain : int, $type : int, $protocol : int);
accept
method accept : IO::Socket ($io_socket_builder : IO::Socket::Builder = undef, $peer_ref : Sys::Socket::Sockaddr[] = undef);
See also Sys::Socket::Sockaddr.
See also IO::Socket::Builder.
peerport
method peerport : int ();
This method is implemented in a child class.
Exceptions:
Not implemented.
peerhost
method peerhost : string ();
This method is implemented in a child class.
Exceptions:
Not implemented.
write
method write : int ($string : string, $length : int = -1, $offset : int = 0);
read
method read : int ($string : mutable string, $length : int = -1, $offset : int = 0);
See Also
Sys::Socket
Sys::Socket::Constant
IO::Socket::INET
Perl's IO::Socket
IO::Socket
is a Perl's IO::Socket porting to SPVM.
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License