Name

SPVM::Sys::Socket::Util - Socket Utilities

Description

The Sys::Socket::Util class in SPVM has methods for socket utilities.

Usage

use Sys::Socket::Util;

Class Methods

inet_aton

static method inet_aton : Sys::Socket::In_addr ($address : string);

Creates a new Sys::Socket::In_addr object and calls the inet_aton method in the Sys::Socket class with it, and returns it.

inet_ntoa

static method inet_ntoa : string ($in_addr : Sys::Socket::In_addr);

Calls the inet_ntoa method in the Sys::Socket class, and returns its return value.

inet_pton

static method inet_pton : Sys::Socket::In_addr_base ($family : int, $address : string);

Creates a new Sys::Socket::In_addr object or a new Sys::Socket::In6_addr according to the address family $family.

And calls the inet_aton method in the Sys::Socket class with it, and returns it.

Excetpions:

If the address family $family is not available, an excetpion is thrown.

inet_ntop

static method inet_ntop : string ($family : int, $in_addr : Sys::Socket::In_addr_base);

Calls the inet_ntop method in the Sys::Socket class given enough address buffer $dst.

And the got address $dst is truncated to the length the address and returns it.

sockaddr_in

static method sockaddr_in : Sys::Socket::Sockaddr::In ($port : int, $in_addr : Sys::Socket::In_addr);

Creates a new Sys::Socket::Sockaddr::In object given the port $port and the address $in_addr, and returns it.

The address family is set to AF_INET.

Exceptions:

$in_addr must be defined. Otherwise an exception is thrown.

sockaddr_in6

static method sockaddr_in6 : Sys::Socket::Sockaddr::In6 ($port : int, $in6_addr : Sys::Socket::In6_addr);

Creates a new Sys::Socket::Sockaddr::In6 object given the port $port and the address $in_addr, and returns it.

The address family is set to AF_INET6.

Exceptions:

$in6_addr must be defined. Otherwise an exception is thrown.

sockaddr_un

static method sockaddr_un : Sys::Socket::Sockaddr::Un ($path : string);

Creates a new Sys::Socket::Sockaddr::Un object given the path $path, and returns it.

The address family is set to AF_UNIX.

Exceptions:

$path must be defined. Otherwise an exception is thrown.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License