Listens for connections from TCP network clients.
Public Constructors | |
tcp_listener (const xtd::net::ip_end_point &local_end_point) | |
Initializes a new instance of the xtd::net::sockets::tcp_listener class with the specified local endpoint. | |
tcp_listener (const xtd::net::ip_address &ip_address, uint16 port) | |
Initializes a new instance of the xtd::net::sockets::tcp_listener class that listens for incoming connection attempts on the specified local IP address and port number. | |
Public Properties | |
bool | exclusive_address_use () const |
Gets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlying socket to listen to a specific port. | |
tcp_listener & | exclusive_address_use (bool value) |
Sets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlying socket to listen to a specific port. | |
const xtd::net::end_point & | local_end_point () const noexcept |
Gets the underlying xtd::net::end_point of the current xtd::net::sockets::tcp_listener. | |
xtd::net::sockets::socket | server () const noexcept |
Gets the underlying network xtd::net::sockets::socket. | |
Public Methods | |
xtd::net::sockets::socket | accept_socket () |
Accepts a pending connection request. | |
xtd::net::sockets::tcp_client | accept_tcp_client () |
Accepts a pending connection request. | |
xtd::sptr< xtd::iasync_result > | begin_accept_socket (xtd::async_callback callback, const std::any &state) |
Begins an asynchronous operation to accept an incoming connection attempt. | |
xtd::sptr< xtd::iasync_result > | begin_accept_tcp_client (xtd::async_callback callback, const std::any &state) |
Begins an asynchronous operation to accept an incoming connection attempt. | |
xtd::net::sockets::socket | end_accept_socket (xtd::sptr< xtd::iasync_result > async_result) |
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication. | |
xtd::net::sockets::tcp_client | end_accept_tcp_client (xtd::sptr< xtd::iasync_result > async_result) |
Asynchronously accepts an incoming connection attempt and creates a new xtd::net::sockets::tcp_client to handle remote host communication. | |
bool | equals (const tcp_listener &s) const noexcept override |
bool | pending () |
Determines if there are pending connection requests. | |
void | start () |
xtd::net::sockets::tcp_listener::starts listening for incoming connection requests. | |
void | start (size_t backlog) |
xtd::net::sockets::tcp_listener::starts listening for incoming connection requests with a maximum number of pending connection. | |
void | stop () |
Closes the listener. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to 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. | |
Public Static Methods | |
static tcp_listener | create (uint16 port) |
Creates a new xtd::net::sockets::tcp_listener instance to listen on the specified port. | |
Protected Properties | |
bool | active () const noexcept |
Gets a value that indicates whether xtd::net::sockets::tcp_listener is actively listening for client connections. | |
Additional Inherited Members | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual size_t | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual xtd::string | to_string () const noexcept |
Returns a xtd::string that represents the current object. | |
Public Member Functions inherited from xtd::iequatable< tcp_listener > | |
virtual bool | equals (const tcp_listener &) const noexcept=0 |
Indicates whether the current object is equal to another object of the same type. | |
Static Public Member Functions inherited from xtd::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. | |
|
explicit |
Initializes a new instance of the xtd::net::sockets::tcp_listener class with the specified local endpoint.
local_end_point | An xtd::net::ip_end_point that represents the local endpoint to which to bind the listener xtd::net::sockets::socket. |
xtd::net::sockets::tcp_listener::tcp_listener | ( | const xtd::net::ip_address & | ip_address, |
uint16 | port | ||
) |
Initializes a new instance of the xtd::net::sockets::tcp_listener class that listens for incoming connection attempts on the specified local IP address and port number.
ip_address | An xtd::net::ip_address that represents the local IP address. |
port | The port on which to listen for incoming connection attempts. |
bool xtd::net::sockets::tcp_listener::exclusive_address_use | ( | ) | const |
Gets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlying socket to listen to a specific port.
xtd::invalid_operation_exception | The xtd::net::sockets::tcp_listener has been started. Call the xtd::net::sockets::tcp_listener::stop() method and then set the xtd::net::sockets::tcp_listener::exclusive_address_use property. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
tcp_listener & xtd::net::sockets::tcp_listener::exclusive_address_use | ( | bool | value | ) |
Sets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlying socket to listen to a specific port.
value | true if the xtd::net::sockets::tcp_listener allows only one xtd::net::sockets::tcp_listener to listen to a specific port; otherwise, false. . |
xtd::invalid_operation_exception | The xtd::net::sockets::tcp_listener has been started. Call the xtd::net::sockets::tcp_listener::stop() method and then set the xtd::net::sockets::tcp_listener::exclusive_address_use property. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
|
noexcept |
Gets the underlying xtd::net::end_point of the current xtd::net::sockets::tcp_listener.
|
noexcept |
Gets the underlying network xtd::net::sockets::socket.
xtd::net::sockets::socket xtd::net::sockets::tcp_listener::accept_socket | ( | ) |
Accepts a pending connection request.
xtd::invalid_operation_exception | The listener has not been started with a call to xtd::net::sockets::tcp_listener::start. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::net::sockets::tcp_client xtd::net::sockets::tcp_listener::accept_tcp_client | ( | ) |
Accepts a pending connection request.
xtd::invalid_operation_exception | The listener has not been started with a call to xtd::net::sockets::tcp_listener::start. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::sptr< xtd::iasync_result > xtd::net::sockets::tcp_listener::begin_accept_socket | ( | xtd::async_callback | callback, |
const std::any & | state | ||
) |
Begins an asynchronous operation to accept an incoming connection attempt.
async_result | An xtd::async_callback delegate that references the method to invoke when the operation is complete. |
state | A user-defined object containing information about the accept operation. This object is passed to the callback delegate when the operation is complete. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
xtd::sptr< xtd::iasync_result > xtd::net::sockets::tcp_listener::begin_accept_tcp_client | ( | xtd::async_callback | callback, |
const std::any & | state | ||
) |
Begins an asynchronous operation to accept an incoming connection attempt.
async_result | An xtd::async_callback delegate that references the method to invoke when the operation is complete. |
state | A user-defined object containing information about the accept operation. This object is passed to the callback delegate when the operation is complete. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
xtd::net::sockets::socket xtd::net::sockets::tcp_listener::end_accept_socket | ( | xtd::sptr< xtd::iasync_result > | async_result | ) |
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host communication.
async_result | tAn xtd::iasync_result returned by a call to the xtd::net::sockets::tcp_listener::begin_accept_socket(xtd::async_callback, std::any) method. |
argument_exception | async_result was not returned by a call to the xtd::net::sockets::tcp_listener::begin_accept_socket method. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
xtd::net::sockets::tcp_client xtd::net::sockets::tcp_listener::end_accept_tcp_client | ( | xtd::sptr< xtd::iasync_result > | async_result | ) |
Asynchronously accepts an incoming connection attempt and creates a new xtd::net::sockets::tcp_client to handle remote host communication.
async_result | An xtd::iasync_result returned by a call to the xtd::net::sockets::tcp_listener::begin_accept_tcp_client(xtd::async_callback, std::any) method. |
state | A user-defined object containing information about the accept operation. This object is passed to the callback delegate when the operation is complete. |
argument_exception | async_result was not returned by a call to the xtd::net::sockets::tcp_listener::begin_accept_tcp_client method. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
bool xtd::net::sockets::tcp_listener::pending | ( | ) |
Determines if there are pending connection requests.
xtd::invalid_operation_exception | The listener has not been started with a call to xtd::net::sockets::tcp_listener::start. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
void xtd::net::sockets::tcp_listener::start | ( | ) |
xtd::net::sockets::tcp_listener::starts listening for incoming connection requests.
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
void xtd::net::sockets::tcp_listener::start | ( | size_t | backlog | ) |
xtd::net::sockets::tcp_listener::starts listening for incoming connection requests with a maximum number of pending connection.
backlog | The maximum length of the pending connections queue. |
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::argument_out_of_range_exception | The backlog parameter is less than zero or exceeds the maximum number of permitted connections. |
xtd::invalid_operation_exception | The underlying xtd::net::sockets::socket is null. |
void xtd::net::sockets::tcp_listener::stop | ( | ) |
Closes the listener.
xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
|
static |
Creates a new xtd::net::sockets::tcp_listener instance to listen on the specified port.
port | The port on which to listen for incoming connection attempts. |
|
protectednoexcept |
Gets a value that indicates whether xtd::net::sockets::tcp_listener is actively listening for client connections.
|
virtualnoexcept |
Determines whether the specified object is equal to the current object.
obj | The object to compare with the current object. |
Reimplemented from xtd::object.
|
inlinestaticnoexcept |
Determines whether the specified object instances are considered equal.
object_a | The first object to compare. |
object_b | The second object to compare. |