33 async_result_socket(std::any async_state) : async_state_(async_state) {}
34 std::any async_state()
const noexcept
override {
return async_state_;}
35 std::shared_mutex& async_mutex()
override {
return async_mutex_;}
36 bool completed_synchronously()
const noexcept
override {
return false;}
37 bool is_completed()
const noexcept
override {
return is_completed_;};
39 std::any async_state_;
40 bool is_completed_ =
false;
41 std::shared_mutex async_mutex_;
43 std::exception_ptr exception_;
46 class async_result_accept_socket :
public async_result_socket {
48 async_result_accept_socket(std::any async_state) : async_result_socket(async_state) {}
52 class async_result_accept_tcp_client :
public async_result_socket {
54 async_result_accept_tcp_client(std::any async_state) : async_result_socket(async_state) {}
83 friend std::ostream& operator <<(std::ostream& os,
const tcp_listener& tl) noexcept {
return os << tl.
to_string();}
84 bool operator==(
const tcp_listener& s)
const {
return data_ ==
s.data_;};
85 bool operator!=(
const tcp_listener& s)
const {
return !operator==(s);};
238 std::shared_ptr<data> data_;
Represents the status of an asynchronous operation.
Definition: iasync_result.h:21
Identifies a network address. This is an abstract class.
Definition: end_point.h:24
Provides an Internet Protocol (IP) address.
Definition: ip_address.h:30
Represents a network endpoint as an IP address and a port number.
Definition: ip_end_point.h:20
Implements the Berkeley sockets interface.
Definition: socket.h:63
Provides client connections for TCP network services.
Definition: tcp_client.h:39
Listens for connections from TCP network clients.
Definition: tcp_listener.h:30
void start()
xtd::net::sockets::tcp_listener::starts listening for incoming connection requests.
bool exclusive_address_use() const
Gets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlyi...
xtd::net::sockets::tcp_client accept_tcp_client()
Accepts a pending connection request.
xtd::net::sockets::socket accept_socket()
Accepts a pending connection request.
static tcp_listener create(uint16_t port)
Creates a new xtd::net::sockets::tcp_listener instance to listen on the specified 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.
std::shared_ptr< xtd::iasync_result > begin_accept_socket(xtd::async_callback callback, const std::any &state)
Begins an asynchronous operation to accept an incoming connection attempt.
bool pending()
Determines if there are pending connection requests.
tcp_listener(const xtd::net::ip_address &ip_address, uint16_t port)
Initializes a new instance of the xtd::net::sockets::tcp_listener class that listens for incoming con...
tcp_listener & exclusive_address_use(bool value)
Sets a bool value that specifies whether the xtd::net::sockets::tcp_listener allows only one underlyi...
std::shared_ptr< 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 server() const noexcept
Gets the underlying network xtd::net::sockets::socket.
bool active() const noexcept
Gets a value that indicates whether xtd::net::sockets::tcp_listener is actively listening for client ...
xtd::net::sockets::socket end_accept_socket(std::shared_ptr< xtd::iasync_result > async_result)
Asynchronously accepts an incoming connection attempt and creates a new Socket to handle remote host ...
xtd::net::sockets::tcp_client end_accept_tcp_client(std::shared_ptr< xtd::iasync_result > async_result)
Asynchronously accepts an incoming connection attempt and creates a new xtd::net::sockets::tcp_client...
void stop()
Closes the listener.
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 endp...
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
virtual xtd::ustring to_string() const noexcept
Returns a std::string that represents the current object.
socket_error
Defines error codes for the xtd::net::sockets::socket class.
Definition: socket_error.h:24
delegate< void(std::shared_ptr< xtd::iasync_result > ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition: async_callback.h:18
@ success
Operation successful.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::net::sockets::tcp_client class.