xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Public Member Functions | List of all members
xtd::net::socket_address Class Reference

#include <socket_address.h>

Definition

Stores serialized information from end_point derived classes.

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 Member Functions

 socket_address (sockets::address_family address_family)
 Creates a new instance of the xtd::net::socket_address class for the given address family. More...
 
 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. More...
 
 socket_address (const std::vector< byte_t > &buffer)
 Creates a new instance of the xtd::net::socket_address class using the specified byte buffer . More...
 
sockets::address_family address_family () const
 Gets the address family to which the endpoint belongs. More...
 
byteoperator[] (size_t index)
 Gets or sets the specified index element in the underlying buffer. More...
 
const byteoperator[] (size_t index) const
 Gets the specified index element in the underlying buffer. More...
 
size_t size () const
 Gets the underlying buffer size of the xtd::net::socket_address. More...
 
xtd::ustring to_string () const noexcept override
 Returns information about the socket address. More...
 
- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object. More...
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object. More...
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type. More...
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal. More...
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance. More...
 

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 std::vector< byte_t > &  buffer)
explicit

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

Member Function Documentation

◆ address_family()

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

Gets the address family to which the endpoint belongs.

Returns
One of the sockets::address_family values.

◆ operator[]() [1/2]

byte& xtd::net::socket_address::operator[] ( size_t  index)

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 xtdd::argument_out_of_range_exception.

◆ operator[]() [2/2]

const byte& xtd::net::socket_address::operator[] ( size_t  index) const

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 xtdd::argument_out_of_range_exception.

◆ size()

size_t xtd::net::socket_address::size ( ) const

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

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

◆ to_string()

xtd::ustring xtd::net::socket_address::to_string ( ) const
overridevirtualnoexcept

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.


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