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

IO::Handle.

Fields

Domain

has Domain : protected int;

Type

has Type : protected int;

Proto

has Proto : protected ro int;

Timeout

has Timeout : protected double;

peername

has peername : protected 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 : Double

  • 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 : double ();

Gets the "Timeout" field.

new_from_instance

method new_from_instance : IO::Socket ($options : object[] = undef);

peername

method peername : Sys::Socket::Sockaddr ();

DESTROY

method DESTROY : void ();

init

protected method init : void ($options : object[] = undef);

connect

method connect : void ($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 : void ($queue : int = 5);

bind

method bind : void ($address : Sys::Socket::Sockaddr);

See also Sys::Socket::Sockaddr.

sockname

method sockname : Sys::Socket::Sockaddr ();

See also Sys::Socket::Sockaddr.

shutdown

method shutdown : void ($sockfd : int, $how : int);

atmark

method atmark : int ();

sockopt

method sockopt : int ($level : int, $optname : int);

setsockopt

method setsockopt : void ($level : int, $optname : int, $optval : object of string|Int)

connected

method connected : Sys::Socket::Sockaddr ();

See also Sys::Socket::Sockaddr.

socket

method socket : void ($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

Sys::Socket::Constant

Sys::Socket::Constant

IO::Socket::INET

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