xtd 0.2.0
Loading...
Searching...
No Matches
xtd::net::socket_address Class Reference
Inheritance diagram for xtd::net::socket_address:
xtd::object xtd::iequatable< xtd::net::socket_address > xtd::interface xtd::extensions::equality_operators< xtd::net::socket_address, iequatable< xtd::net::socket_address > >

Definition

Stores serialized information from end_point derived classes. #par Deinition.

class core_export_ socket_address : public xtd::object, public xtd::iequatable<xtd::net::socket_address>;
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
socket_address(sockets::address_family address_family)
Creates a new instance of the xtd::net::socket_address class for the given address family.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
#define core_export_
Define shared library export.
Definition core_export.hpp:13
Header
#include <xtd/net/socket_address>
Namespace
xtd::net
Library
xtd.core
Remarks
The first 2 bytes of the underlying buffer are reserved for the xtd::net::sockets::address_family enumerated value. When the xtd::net::socket_address is used to store a serialized xtd::net::ipend_point, the third and fourth bytes are used to store port number information. The next bytes are used to store the IP address. You can access any information within this underlying byte buffer by referring to its index position; the byte buffer uses zero-based indexing. You can also use the xtd::net::socket_address::family and xtd::net::socket_address::size properties to get the xtd::net::sockets::address_family value and the buffer size, respectively. To view any of this information as a string, use the xtd::net::socket_address::to_string method.

Public Constructors

 socket_address (sockets::address_family address_family)
 Creates a new instance of the xtd::net::socket_address class for the given address family.
 
 socket_address (sockets::address_family address_family, size_t buffer_size)
 Creates a new instance of the xtd::net::socket_address class using the specified address family and buffer size.
 
 socket_address (const xtd::array< xtd::byte > &buffer)
 Creates a new instance of the xtd::net::socket_address class using the specified byte buffer .
 

Public Properties

auto address_family () const -> xtd::net::sockets::address_family
 Gets the address family to which the endpoint belongs.
 
auto size () const -> xtd::size
 Gets the underlying buffer size of the xtd::net::socket_address.
 

Public Methods

auto equals (const xtd::object &obj) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
 
auto equals (const socket_address &other) const noexcept -> bool override
 Determines whether the specified object is equal to the current object.
 
auto get_hash_code () const noexcept -> xtd::size override
 Serves as a hash function for a particular type.
 
auto to_string () const noexcept -> xtd::string override
 Returns information about the socket address.
 

Public Operators

auto operator[] (xtd::size index) -> xtd::byte &
 Gets or sets the specified index element in the underlying buffer.
 
auto operator[] (xtd::size index) const -> const xtd::byte &
 Gets the specified index element in the underlying buffer.
 

Additional Inherited Members

 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
template<class object_a_t, class object_b_t>
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t, class object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ socket_address() [1/3]

xtd::net::socket_address::socket_address ( sockets::address_family address_family)
explicit

Creates a new instance of the xtd::net::socket_address class for the given address family.

◆ socket_address() [2/3]

xtd::net::socket_address::socket_address ( sockets::address_family address_family,
size_t buffer_size )

Creates a new instance of the xtd::net::socket_address class using the specified address family and buffer size.

◆ socket_address() [3/3]

xtd::net::socket_address::socket_address ( const xtd::array< xtd::byte > & buffer)
explicit

Creates a new instance of the xtd::net::socket_address class using the specified byte buffer .

Member Function Documentation

◆ address_family()

auto xtd::net::socket_address::address_family ( ) const -> xtd::net::sockets::address_family
nodiscard

Gets the address family to which the endpoint belongs.

Returns
One of the sockets::address_family values.

◆ size()

auto xtd::net::socket_address::size ( ) const -> xtd::size
nodiscard

Gets the underlying buffer size of the xtd::net::socket_address.

Returns
The underlying buffer size of the xtd::net::socket_address.

◆ equals() [1/2]

auto xtd::net::socket_address::equals ( const xtd::object & obj) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

auto xtd::net::socket_address::equals ( const socket_address & other) const -> bool
nodiscardoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
otherThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.

Implements xtd::iequatable< xtd::net::socket_address >.

◆ get_hash_code()

auto xtd::net::socket_address::get_hash_code ( ) const -> xtd::size
nodiscardoverridevirtualnoexcept

Serves as a hash function for a particular type.

Returns
A hash code for the current object.

Reimplemented from xtd::object.

◆ to_string()

auto xtd::net::socket_address::to_string ( ) const -> xtd::string
nodiscardoverridevirtualnoexcept

Returns information about the socket address.

Returns
A string that contains information about the xtd::net::socket_address.
Remarks
The xtd::net::socket_address::to_string method returns a string that contains the xtd::net::sockets::address_family enumerated value, the size of the underlying buffer of the socket_address structure, and the remaining contents of the buffer.

Reimplemented from xtd::object.

◆ operator[]() [1/2]

auto xtd::net::socket_address::operator[] ( xtd::size index) -> xtd::byte &

Gets or sets the specified index element in the underlying buffer.

Parameters
indexThe array index element of the desired information.
Returns
The value of the specified index element in the underlying buffer.
Exceptions
xtd::argument_out_of_range_exceptionindex is equal to or greater than size.
Remarks
This property gets or sets the specified byte position in the underlying buffer.
Note
Be sure to call xtd::net::socket_address::size before referring to elements in the underlying buffer. Referring to an index that does not exist will cause the xtd::net::socket_address to throw an xtd::argument_out_of_range_exception.

◆ operator[]() [2/2]

auto xtd::net::socket_address::operator[] ( xtd::size index) const -> const xtd::byte &

Gets the specified index element in the underlying buffer.

Parameters
indexThe array index element of the desired information.
Returns
The value of the specified index element in the underlying buffer.
Exceptions
xtd::argument_out_of_range_exceptionindex is equal to or greater than size.
Remarks
This property gets or sets the specified byte position in the underlying buffer.
Note
Be sure to call xtd::net::socket_address::size before referring to elements in the underlying buffer. Referring to an index that does not exist will cause the xtd::net::socket_address to throw an xtd::argument_out_of_range_exception.

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