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
Domain
has Domain : protected int;
Type
has Type : protected int;
Proto
has Proto : protected ro int;
Timeout
has Timeout : protected int;
peername
has peername : protected ro Sys::Socket::Sockaddr;
See also Sys::Socket::Sockaddr.
Listen
has Listen : protected int;
Class Methods
new
static method new : IO::Socket ($options : object[] = undef);
The socket is set to non-blocking mode.
new Options
Domain : Int
Type : Int
Proto : Int
Blocking : Int
Timeout : Int
Listen : Int
See also SPVM::Sys::Socket::Constant.
Instance Methods
sockdomain
method sockdomain : int ();
Gets the "Domain" field.
socktype
method socktype : int ();
Gets the "Type" field.
protocol
method protocol : int ();
Gets the "Proto" field.
timeout
method timeout : int ();
Gets the "Timeout" field.
new_from_instance
method new_from_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, $buf_offset : int = 0);
send
method send : int ($buffer : string, $flags : int = 0, $to : Sys::Socket::Sockaddr = undef, $length : int = -1, $buf_offset : int = 0);
See also Sys::Socket::Sockaddr.
close
method close : int ();
fileno
method fileno : int (); return $self->{fd}; }
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 ();
sockopt
method sockopt : int ($level : int, $optname : int);
set_sockopt
method set_sockopt : int ($level : int, $optname : int, $optval : 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