xtd 0.2.0
Loading...
Searching...
No Matches
xtd::native::socket Class Referencefinal

Definition

Contains translator native API.

Namespace
xtd::native
Library
xtd.core.native
Warning
Internal use only

Protected Methods

static int32_t address_family_to_native (int32_t address_family)
 Gets the native address family value corresponding to xtd address family.
 
static int32_t native_to_address_family (int32_t address_family)
 Gets the xtd address family value corresponding to native address family.
 
static intmax_t accept (intmax_t handle, std::vector< uint8_t > &socket_address)
 Accepts a connection on a socket.
 
static int32_t bind (intmax_t handle, const std::vector< uint8_t > &socket_address)
 Binds a name to a socket.
 
static void cleanup ()
 Cleanup the socket library.
 
static int32_t connect (intmax_t handle, const std::vector< uint8_t > &socket_address)
 Initiates a connection on a socket.
 
static intmax_t create (int32_t address_family, int32_t socket_type, int32_t protocol_type)
 Creates an endpoint for communication.
 
static int32_t destroy (intmax_t handle)
 Destroys the socket.
 
static size_t get_available (intmax_t handle)
 Gets the amount of data that has been received from the network and is available to be read.
 
static int32_t get_last_error ()
 Gets last error.
 
static bool get_os_supports_ip_v4 () noexcept
 Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4).
 
static bool get_os_supports_ip_v6 () noexcept
 Indicates whether the underlying operating system and network adaptors support Internet Protocol version 6 (IPv6).
 
static int32_t get_raw_socket_option (intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t &option_length)
 Gets options on socket.
 
static int32_t get_socket_option (intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t &option_length)
 Gets options on socket.
 
static int32_t get_socket_linger_option (intmax_t handle, bool &enabled, uint32_t &linger_time)
 Gets linger option on socket.
 
static int32_t get_socket_multicast_option (intmax_t handle, int32_t socket_option_name, uint32_t &multicast_address, uint32_t &interface_index)
 Gets multicast option on socket.
 
static int32_t get_socket_ip_v6_multicast_option (intmax_t handle, int32_t socket_option_name, std::vector< uint8_t > &multicast_address, uint32_t &interface_index)
 Gets IP v6 multicast option on socket.
 
static int32_t io_control (intmax_t handle, int32_t io_control, std::vector< uint8_t > &option_in_value, std::vector< uint8_t > &option_out_value)
 Sets low-level operating modes for the Socket using the IOControlCode enumeration to specify control codes.
 
static int32_t listen (intmax_t handle, size_t backlog)
 Listens for connections on a socket.
 
static int32_t poll (intmax_t handle, int32_t microseconds, int32_t mode)
 Synchronous I/O multiplexing.
 
static int32_t receive (intmax_t handle, std::vector< uint8_t > &buffer, size_t offset, size_t size, int32_t flags)
 Receives a message from a socket.
 
static int32_t receive_from (intmax_t handle, std::vector< uint8_t > &buffer, size_t offset, size_t size, int32_t flags, std::vector< uint8_t > &socket_address)
 Receives a message from a socket.
 
static int32_t select (std::vector< intmax_t > &check_read, std::vector< intmax_t > &check_write, std::vector< intmax_t > &check_error, int32_t microseconds)
 Determines the status of one or more sockets.
 
static int32_t send (intmax_t handle, const std::vector< uint8_t > &buffer, size_t offset, size_t size, int32_t flags)
 send a message from a socket.
 
static int32_t send_to (intmax_t handle, const std::vector< uint8_t > &buffer, size_t offset, size_t size, int32_t flags, const std::vector< uint8_t > &socket_address)
 send a message from a socket.
 
static int32_t set_blocking (intmax_t handle, bool blocking)
 Sets a value that indicates whether the socket is in blocking mode.
 
static int32_t set_raw_socket_option (intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length)
 Sets options on socket.
 
static int32_t set_socket_option (intmax_t handle, int32_t socket_option_level, int32_t socket_option_name, intmax_t option, size_t option_length)
 Sets options on socket.
 
static int32_t set_socket_linger_option (intmax_t handle, bool enabled, uint32_t linger_time)
 Sets linger option on socket.
 
static int32_t set_socket_multicast_option (intmax_t handle, int32_t socket_option_name, uint32_t multicast_address, uint32_t interface_index)
 Sets multicast option on socket.
 
static int32_t set_socket_ip_v6_multicast_option (intmax_t handle, int32_t socket_option_name, const std::vector< uint8_t > &multicast_address, uint32_t interface_index)
 Sets IP v6 multicast option on socket.
 
static int32_t shutdown (intmax_t handle, int32_t how)
 Shut down part of a full-duplex connection.
 
static void startup ()
 Startup the socket library.
 

Member Function Documentation

◆ address_family_to_native()

static int32_t xtd::native::socket::address_family_to_native ( int32_t  address_family)
staticprotected

Gets the native address family value corresponding to xtd address family.

Returns
The native address family value corresponding to xtd address family (see address_family_constants.h).
Warning
Internal use only

◆ native_to_address_family()

static int32_t xtd::native::socket::native_to_address_family ( int32_t  address_family)
staticprotected

Gets the xtd address family value corresponding to native address family.

Returns
The xtd address family value corresponding to native address family (see address_family_constants.h).
Warning
Internal use only

◆ accept()

static intmax_t xtd::native::socket::accept ( intmax_t  handle,
std::vector< uint8_t > &  socket_address 
)
staticprotected

Accepts a connection on a socket.

Parameters
handleThe socket handle.
socket_addressA byte array socket address is a result parameter that is filled in with the address of the connecting entity, as known to the communications layer.
Returns
The new socket handle created.
Warning
Internal use only

◆ bind()

static int32_t xtd::native::socket::bind ( intmax_t  handle,
const std::vector< uint8_t > &  socket_address 
)
staticprotected

Binds a name to a socket.

Parameters
handleThe socket handle.
socket_addressA byte array socket address to bind.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ cleanup()

static void xtd::native::socket::cleanup ( )
staticprotected

Cleanup the socket library.

Warning
Internal use only

◆ connect()

static int32_t xtd::native::socket::connect ( intmax_t  handle,
const std::vector< uint8_t > &  socket_address 
)
staticprotected

Initiates a connection on a socket.

Parameters
handleThe socket handle.
socket_addressA byte array socket address to connect.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ create()

static intmax_t xtd::native::socket::create ( int32_t  address_family,
int32_t  socket_type,
int32_t  protocol_type 
)
staticprotected

Creates an endpoint for communication.

Parameters
address_familyOne of address family values (see address_family_constants.h).
socket_typeOne of socket type values (see socket_type_constants.h).
protocol_typeOne of protocol type values (see protocol_type_constants.h).
Returns
The new socket handle created.
Warning
Internal use only

◆ destroy()

static int32_t xtd::native::socket::destroy ( intmax_t  handle)
staticprotected

Destroys the socket.

Parameters
handleThe socket handle.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ get_available()

static size_t xtd::native::socket::get_available ( intmax_t  handle)
staticprotected

Gets the amount of data that has been received from the network and is available to be read.

Parameters
handleThe socket handle.
Returns
The number of bytes of data received from the network and available to be read.
Remarks
Return -1 if error.
Warning
Internal use only

◆ get_last_error()

static int32_t xtd::native::socket::get_last_error ( )
staticprotected

Gets last error.

Returns
One of socket error value (see socket_error_constants.h).
Warning
Internal use only

◆ get_os_supports_ip_v4()

static bool xtd::native::socket::get_os_supports_ip_v4 ( )
staticprotectednoexcept

Indicates whether the underlying operating system and network adaptors support Internet Protocol version 4 (IPv4).

Returns
bool true if the operating system and network adaptors support the IPv4 protocol; otherwise, false.
Warning
Internal use only

◆ get_os_supports_ip_v6()

static bool xtd::native::socket::get_os_supports_ip_v6 ( )
staticprotectednoexcept

Indicates whether the underlying operating system and network adaptors support Internet Protocol version 6 (IPv6).

Returns
bool true if the operating system and network adaptors support the IPv6 protocol; otherwise, false.
Warning
Internal use only

◆ get_raw_socket_option()

static int32_t xtd::native::socket::get_raw_socket_option ( intmax_t  handle,
int32_t  socket_option_level,
int32_t  socket_option_name,
intmax_t  option,
size_t &  option_length 
)
staticprotected

Gets options on socket.

Parameters
handleThe socket handle.
socket_option_levelThe platform-defined option level.
socket_option_nameThe platform-defined option name.
optionThe option is a result parameter of that is filled with the option value.
option_lengthThe option size will contains the size of option value.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ get_socket_option()

static int32_t xtd::native::socket::get_socket_option ( intmax_t  handle,
int32_t  socket_option_level,
int32_t  socket_option_name,
intmax_t  option,
size_t &  option_length 
)
staticprotected

Gets options on socket.

Parameters
handleThe socket handle.
socket_option_levelOne of socket option level values (see socket_option_level_constants.h).
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
optionThe option is a result parameter of that is filled with the option value.
option_lengthThe option size will contains the size of option value.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ get_socket_linger_option()

static int32_t xtd::native::socket::get_socket_linger_option ( intmax_t  handle,
bool &  enabled,
uint32_t &  linger_time 
)
staticprotected

Gets linger option on socket.

Parameters
handleThe socket handle.
enabledIndicates whether to linger after the socket is closed..
linger_timeThe amount of time to remain connected after calling the socket close method if data remains to be sent.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ get_socket_multicast_option()

static int32_t xtd::native::socket::get_socket_multicast_option ( intmax_t  handle,
int32_t  socket_option_name,
uint32_t &  multicast_address,
uint32_t &  interface_index 
)
staticprotected

Gets multicast option on socket.

Parameters
handleThe socket handle.
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
multicast_addressThe local IP address associated with a multicast group.
interface_indexThe interface index that is associated with a multicast group.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ get_socket_ip_v6_multicast_option()

static int32_t xtd::native::socket::get_socket_ip_v6_multicast_option ( intmax_t  handle,
int32_t  socket_option_name,
std::vector< uint8_t > &  multicast_address,
uint32_t &  interface_index 
)
staticprotected

Gets IP v6 multicast option on socket.

Parameters
handleThe socket handle.
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
multicast_addressThe local IP address associated with a multicast group.
interface_indexThe interface index that is associated with a multicast group.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ io_control()

static int32_t xtd::native::socket::io_control ( intmax_t  handle,
int32_t  io_control,
std::vector< uint8_t > &  option_in_value,
std::vector< uint8_t > &  option_out_value 
)
staticprotected

Sets low-level operating modes for the Socket using the IOControlCode enumeration to specify control codes.

Parameters
handleThe socket handle.
io_controlA io control code value that specifies the control code of the operation to perform (see io_control_code_constants.h).
option_in_valueAn array of type byte that contains the input data required by the operation.
option_out_valueAn array of type byte that contains the output data returned by the operation.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ listen()

static int32_t xtd::native::socket::listen ( intmax_t  handle,
size_t  backlog 
)
staticprotected

Listens for connections on a socket.

Parameters
handleThe socket handle.
backlogThe maximum length for the queue of pending connections.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ poll()

static int32_t xtd::native::socket::poll ( intmax_t  handle,
int32_t  microseconds,
int32_t  mode 
)
staticprotected

Synchronous I/O multiplexing.

Parameters
handleThe socket handle.
microsecondsTimeout in microseconds.
modeOne of select mode value (see select_mode_constants.h).
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ receive()

static int32_t xtd::native::socket::receive ( intmax_t  handle,
std::vector< uint8_t > &  buffer,
size_t  offset,
size_t  size,
int32_t  flags 
)
staticprotected

Receives a message from a socket.

Parameters
handleThe socket handle.
bufferAn array of type byte that is the storage location for the received data.
offsetThe location in buffer to store the received data.
sizeThe number of bytes to receive.
flagsA bitwise combination of the socket flags values. (see socket_flags_constants.h)
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ receive_from()

static int32_t xtd::native::socket::receive_from ( intmax_t  handle,
std::vector< uint8_t > &  buffer,
size_t  offset,
size_t  size,
int32_t  flags,
std::vector< uint8_t > &  socket_address 
)
staticprotected

Receives a message from a socket.

Parameters
handleThe socket handle.
bufferAn array of type byte that is the storage location for the received data.
offsetThe location in buffer to store the received data.
sizeThe number of bytes to receive.
flagsA bitwise combination of the socket flags values. (see socket_flags_constants.h)
socket_addressA byte array socket address to receive from.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ select()

static int32_t xtd::native::socket::select ( std::vector< intmax_t > &  check_read,
std::vector< intmax_t > &  check_write,
std::vector< intmax_t > &  check_error,
int32_t  microseconds 
)
staticprotected

Determines the status of one or more sockets.

Parameters
check_readAn xtd::collections::generic::ilist of Socket instances to check for readability.
check_writeAn xtd::collections::generic::ilist of Socket instances to check for writability.
check_errorAn xtd::collections::generic::ilist of Socket instances to check for errors.
microsecondsThe time-out value, in microseconds. A -1 value indicates an infinite time-out.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ send()

static int32_t xtd::native::socket::send ( intmax_t  handle,
const std::vector< uint8_t > &  buffer,
size_t  offset,
size_t  size,
int32_t  flags 
)
staticprotected

send a message from a socket.

Parameters
bufferAn array of type Byte that contains the data to be sent.
offsetTThe position in the data buffer at which to begin sending data.
sizeThe number of bytes to send.
flagsA bitwise combination of the socket flags values. (see socket_flags_constants.h)
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ send_to()

static int32_t xtd::native::socket::send_to ( intmax_t  handle,
const std::vector< uint8_t > &  buffer,
size_t  offset,
size_t  size,
int32_t  flags,
const std::vector< uint8_t > &  socket_address 
)
staticprotected

send a message from a socket.

Parameters
handleThe socket handle.
bufferAn array of type Byte that contains the data to be sent.
offsetTThe position in the data buffer at which to begin sending data.
sizeThe number of bytes to send.
flagsA bitwise combination of the socket flags values. (see socket_flags_constants.h)
socket_addressA byte array socket address to send to.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_blocking()

static int32_t xtd::native::socket::set_blocking ( intmax_t  handle,
bool  blocking 
)
staticprotected

Sets a value that indicates whether the socket is in blocking mode.

Parameters
handleThe socket handle.
blockingbool true if the Socket will block; otherwise, false. The default is true
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_raw_socket_option()

static int32_t xtd::native::socket::set_raw_socket_option ( intmax_t  handle,
int32_t  socket_option_level,
int32_t  socket_option_name,
intmax_t  option,
size_t  option_length 
)
staticprotected

Sets options on socket.

Parameters
handleThe socket handle.
socket_option_levelThe platform-defined option name.
socket_option_nameThe value to which the option should be set.
optionContains the option value.
option_lengthContains the option value size.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_socket_option()

static int32_t xtd::native::socket::set_socket_option ( intmax_t  handle,
int32_t  socket_option_level,
int32_t  socket_option_name,
intmax_t  option,
size_t  option_length 
)
staticprotected

Sets options on socket.

Parameters
handleThe socket handle.
socket_option_levelOne of socket option level values (see socket_option_level_constants.h).
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
optionContains the option value.
option_lengthContains the option value size.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_socket_linger_option()

static int32_t xtd::native::socket::set_socket_linger_option ( intmax_t  handle,
bool  enabled,
uint32_t  linger_time 
)
staticprotected

Sets linger option on socket.

Parameters
handleThe socket handle.
enabledIndicates whether to linger after the socket is closed..
linger_timeThe amount of time to remain connected after calling the socket close method if data remains to be sent.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_socket_multicast_option()

static int32_t xtd::native::socket::set_socket_multicast_option ( intmax_t  handle,
int32_t  socket_option_name,
uint32_t  multicast_address,
uint32_t  interface_index 
)
staticprotected

Sets multicast option on socket.

Parameters
handleThe socket handle.
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
multicast_addressThe local IP address associated with a multicast group.
interface_indexThe interface index that is associated with a multicast group.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ set_socket_ip_v6_multicast_option()

static int32_t xtd::native::socket::set_socket_ip_v6_multicast_option ( intmax_t  handle,
int32_t  socket_option_name,
const std::vector< uint8_t > &  multicast_address,
uint32_t  interface_index 
)
staticprotected

Sets IP v6 multicast option on socket.

Parameters
handleThe socket handle.
socket_option_nameOne of socket option name values (see socket_option_name_constants.h).
multicast_addressThe local IP address associated with a multicast group.
interface_indexThe interface index that is associated with a multicast group.
linger_timeThe amount of time to remain connected after calling the socket close method if data remains to be sent.
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ shutdown()

static int32_t xtd::native::socket::shutdown ( intmax_t  handle,
int32_t  how 
)
staticprotected

Shut down part of a full-duplex connection.

Parameters
handleThe socket handle.
howOne of socket shutdown values (see socket_shutdown_constants.h).
Returns
Zero (0) if succeed; otherwise on error.
Warning
Internal use only

◆ startup()

static void xtd::native::socket::startup ( )
staticprotected

Startup the socket library.

Warning
Internal use only

The documentation for this class was generated from the following file: