Provides client connections for TCP network services.
Public Constructors | |
| tcp_client () | |
| Initializes a new instance of the xtd::net::sockets::tcp_client class. | |
| tcp_client (const xtd::net::ip_end_point &end_point) | |
| Initializes a new instance of the xtd::net::sockets::tcp_client class and binds it to the specified local endpoint. | |
| tcp_client (xtd::net::sockets::address_family address_family) | |
| The xtd::net::sockets::address_family of the IP protocol. | |
| tcp_client (const xtd::string &hostname, uint16 port) | |
| Initializes a new instance of the xtd::net::sockets::tcp_client class and connects to the specified port on the specified host. | |
Public Properties | |
| auto | available () const -> xtd::size |
| Gets the amount of data that has been received from the network and is available to be read. | |
| auto | client () const noexcept -> xtd::net::sockets::socket |
| Gets the underlying network xtd::net::sockets::socket. | |
| auto | client (const xtd::net::sockets::socket &value) noexcept -> tcp_client & |
| Sets the underlying network xtd::net::sockets::socket. | |
| auto | connected () const noexcept -> bool |
| Gets a value indicating whether the underlying xtd::net::sockets::socket for a xtd::net::sockets::tcp_client is connected to a remote host. | |
| auto | exclusive_address_use () const -> bool |
| Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port. | |
| auto | exclusive_address_use (bool value) -> tcp_client & |
| Sets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port. | |
| auto | linger_state () const -> xtd::net::sockets::linger_option |
| Gets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data. | |
| auto | linger_state (const xtd::net::sockets::linger_option &value) -> tcp_client & |
| Sets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data. | |
| auto | no_delay () const -> bool |
| Gets a value that disables a delay when send or receive buffers are not full. | |
| auto | no_delay (bool value) -> tcp_client & |
| Sets a value that disables a delay when send or receive buffers are not full. | |
| auto | receive_buffer_size () const -> xtd::size |
| Gets the size of the receive buffer. | |
| auto | receive_buffer_size (xtd::size value) -> tcp_client & |
| Sets the size of the receive buffer. | |
| auto | receive_timeout () const -> xtd::int32 |
| Gets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated. | |
| auto | receive_timeout (xtd::int32 value) -> tcp_client & |
| Sets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated. | |
| auto | send_buffer_size () const -> xtd::size |
| Gets the size of the send buffer. | |
| auto | send_buffer_size (xtd::size value) -> tcp_client & |
| Sets the size of the send buffer. | |
| auto | send_timeout () const -> xtd::int32 |
| Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully. | |
| auto | send_timeout (xtd::int32 value) -> tcp_client & |
| Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully. | |
Public Methods | |
| auto | begin_connect (const xtd::net::ip_address &address, uint16 port, xtd::async_callback callback, const xtd::any_object &state) -> xtd::sptr< xtd::iasync_result > |
| Begins an asynchronous request for a remote host connection. The remote host is specified by an xtd::net::ip_address and a port number (uint16). | |
| auto | begin_connect (const xtd::array< xtd::net::ip_address > &addresses, uint16 port, xtd::async_callback callback, const xtd::any_object &state) -> xtd::sptr< xtd::iasync_result > |
| Begins an asynchronous request for a remote host connection. The remote host is specified by an xtd::net::ip_address array and a port number (uint16). | |
| auto | begin_connect (const xtd::string &host, uint16 port, xtd::async_callback callback, const xtd::any_object &state) -> xtd::sptr< xtd::iasync_result > |
| Begins an asynchronous request for a remote host connection. The remote host is specified by a host name (xtd::string) and a port number (uint16). | |
| auto | close () -> void |
| Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection be closed. | |
| auto | connect (const xtd::net::ip_end_point &remote_end_point) -> void |
| Connects the client to a remote TCP host using the specified remote network endpoint. | |
| auto | connect (const xtd::net::ip_address &ip_address, uint16 port) -> void |
| Connects the client to a remote TCP host using the specified IP address and port number. | |
| auto | connect (const xtd::string &hostname, uint16 port) -> void |
| Connects the client to the specified port on the specified host. | |
| auto | end_connect (xtd::sptr< xtd::iasync_result > async_result) -> void |
| Ends a pending asynchronous connection attempt. | |
| auto | equals (const object &obj) const noexcept -> bool override |
| Determines whether the specified object is equal to the current object. | |
| auto | equals (const tcp_client &other) const noexcept -> bool override |
| Determines whether the specified object is equal to the current object. | |
| auto | get_stream () const -> xtd::net::sockets::network_stream |
| Returns the xtd::net::sockets::network_stream used to send and receive data. | |
Protected Properties | |
| auto | active () const noexcept -> bool |
| Gets a value that indicates whether a connection has been made. | |
| auto | active (bool value) noexcept -> tcp_client & |
| Sets a value that indicates whether a connection has been made. | |
Additional Inherited Members | |
| object ()=default | |
| Create a new instance of the ultimate base class object. | |
| virtual xtd::size | 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::unique_ptr_object< object_t > | memberwise_clone () const |
| Creates a shallow copy of the current object. | |
| virtual xtd::string | to_string () const |
| Returns a xtd::string that represents the current object. | |
| virtual bool | equals (const tcp_client &) const noexcept=0 |
| Indicates whether the current object is equal to another object of the same type. | |
| 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. | |
| xtd::net::sockets::tcp_client::tcp_client | ( | ) |
Initializes a new instance of the xtd::net::sockets::tcp_client class.
|
explicit |
Initializes a new instance of the xtd::net::sockets::tcp_client class and binds it to the specified local endpoint.
| local_end_point | The xtd::net::ip_end_point to which you bind the TCP xtd::net::sockets::socket. |
|
explicit |
The xtd::net::sockets::address_family of the IP protocol.
| xtd::argument_exception | The family parameter is not equal to xtd::net::sockets::address_family::inter_network -or- The family parameter is not equal to xtd::net::sockets::address_family::inter_network_v6. |
| xtd::net::sockets::tcp_client::tcp_client | ( | const xtd::string & | hostname, |
| uint16 | port ) |
Initializes a new instance of the xtd::net::sockets::tcp_client class and connects to the specified port on the specified host.
| hostname | The DNS name of the remote host to which you intend to connect. |
| port | The port number of the remote host to which you intend to connect. |
| 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. |
|
nodiscard |
Gets the amount of data that has been received from the network and is available to be read.
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
|
nodiscardnoexcept |
Gets the underlying network xtd::net::sockets::socket.
|
noexcept |
Sets the underlying network xtd::net::sockets::socket.
| value | The underlying network xtd::net::sockets::socket |
|
nodiscardnoexcept |
Gets a value indicating whether the underlying xtd::net::sockets::socket for a xtd::net::sockets::tcp_client is connected to a remote host.
true if the xtd::net::sockets::tcp_client::client was connected to a remote resource as of the most recent operation; otherwise, false. false, true. Note that this behavior is by design.
|
nodiscard |
Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port.
true if the xtd::net::sockets::tcp_client allows only one client to use a specific port; otherwise, false. | xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| auto xtd::net::sockets::tcp_client::exclusive_address_use | ( | bool | value | ) | -> tcp_client & |
Sets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port.
| value | bool true if the xtd::net::sockets::tcp_client allows only one client to use a specific port; otherwise, false. |
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
|
nodiscard |
Gets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data.
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| xtd::net::sockets::linger_option::enabled | xtd::net::sockets::linger_option::linger_time | Behavior |
|---|---|---|
false (disabled), the default value | The time-out is not applicable, (default). | Attempts to send pending data until the default IP protocol time-out expires. |
true (enabled) | A nonzero time-out | Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection. |
true (enabled) | A zero timeout. | Discards any pending data and Winsock resets the connection. |
| auto xtd::net::sockets::tcp_client::linger_state | ( | const xtd::net::sockets::linger_option & | value | ) | -> tcp_client & |
Sets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data.
| value | A xtd::net::sockets::linger_option that specifies how to linger while closing a socket. |
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| xtd::net::sockets::linger_option::enabled | xtd::net::sockets::linger_option::linger_time | Behavior |
|---|---|---|
false (disabled), the default value | The time-out is not applicable, (default). | Attempts to send pending data until the default IP protocol time-out expires. |
true (enabled) | A nonzero time-out | Attempts to send pending data until the specified time-out expires, and if the attempt fails, then Winsock resets the connection. |
true (enabled) | A zero timeout. | Discards any pending data and Winsock resets the connection. |
|
nodiscard |
Gets a value that disables a delay when send or receive buffers are not full.
true if the delay is disabled; otherwise, false. The default value is false. | xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
false, a xtd::net::sockets::tcp_client does not send a packet over the network until it has collected a significant amount of outgoing data. | auto xtd::net::sockets::tcp_client::no_delay | ( | bool | value | ) | -> tcp_client & |
Sets a value that disables a delay when send or receive buffers are not full.
| value | true if the delay is disabled; otherwise, false. The default value is false. |
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
false, a xtd::net::sockets::tcp_client does not send a packet over the network until it has collected a significant amount of outgoing data.
|
nodiscard |
Gets the size of the receive buffer.
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| auto xtd::net::sockets::tcp_client::receive_buffer_size | ( | xtd::size | value | ) | -> tcp_client & |
Sets the size of the receive buffer.
| value | A xtd::size that contains the size, in bytes, of the receive buffer. The default is 8192. |
| xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. See the Remarks section for more information. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
|
nodiscard |
Gets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated.
| auto xtd::net::sockets::tcp_client::receive_timeout | ( | xtd::int32 | value | ) | -> tcp_client & |
Sets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated.
| value | The time-out value of the connection in milliseconds. The default value is 0. |
|
nodiscard |
Gets the size of the send buffer.
| auto xtd::net::sockets::tcp_client::send_buffer_size | ( | xtd::size | value | ) | -> tcp_client & |
Sets the size of the send buffer.
| value | The size of the send buffer, in bytes. The default value is 8192 bytes. |
|
nodiscard |
Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully.
| auto xtd::net::sockets::tcp_client::send_timeout | ( | xtd::int32 | value | ) | -> tcp_client & |
Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully.
| value | The send time-out value, in milliseconds. The default value is 0. |
| auto xtd::net::sockets::tcp_client::begin_connect | ( | const xtd::net::ip_address & | address, |
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const xtd::any_object & | state ) -> xtd::sptr< xtd::iasync_result > |
Begins an asynchronous request for a remote host connection. The remote host is specified by an xtd::net::ip_address and a port number (uint16).
| address | The xtd::net::ip_address of the remote host. |
| port | The port number of the remote host. |
| callback | An xtd::async_callback delegate that references the method to invoke when the operation is complete. |
| state | A user-defined object that contains information about the connect 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. |
| auto xtd::net::sockets::tcp_client::begin_connect | ( | const xtd::array< xtd::net::ip_address > & | addresses, |
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const xtd::any_object & | state ) -> xtd::sptr< xtd::iasync_result > |
Begins an asynchronous request for a remote host connection. The remote host is specified by an xtd::net::ip_address array and a port number (uint16).
| addresses | At least one xtd::net::ip_address that designates the remote hosts. |
| port | The port number of the remote host. |
| callback | An xtd::async_callback delegate that references the method to invoke when the operation is complete. |
| state | A user-defined object that contains information about the connect operation. This object is passed to the requestCallback 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. |
| auto xtd::net::sockets::tcp_client::begin_connect | ( | const xtd::string & | host, |
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const xtd::any_object & | state ) -> xtd::sptr< xtd::iasync_result > |
Begins an asynchronous request for a remote host connection. The remote host is specified by a host name (xtd::string) and a port number (uint16).
| host | The name of the remote host. |
| port | The port number of the remote host. |
| callback | An xtd::async_callback delegate that references the method to invoke when the operation is complete. |
| state | A user-defined object that contains information about the connect operation. This object is passed to the requestCallback 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. |
| auto xtd::net::sockets::tcp_client::close | ( | ) | -> void |
Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection be closed.
| auto xtd::net::sockets::tcp_client::connect | ( | const xtd::net::ip_end_point & | remote_end_point | ) | -> void |
Connects the client to a remote TCP host using the specified remote network endpoint.
| remote_end_point | The xtd::net::ip_end_point to which you intend to connect. |
| xtd::net::sockets::socket_exception | An error occurred when accessing the socket. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| auto xtd::net::sockets::tcp_client::connect | ( | const xtd::net::ip_address & | ip_address, |
| uint16 | port ) -> void |
Connects the client to a remote TCP host using the specified IP address and port number.
| ip_address | The xtd::net::ip_address of the remote host to which you intend to send data |
| port | The port number to which you intend send data |
| xtd::net::sockets::socket_exception | An error occurred when accessing the socket. |
| xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
| auto xtd::net::sockets::tcp_client::connect | ( | const xtd::string & | hostname, |
| uint16 | port ) -> void |
Connects the client to the specified port on the specified host.
| hostname | The DNS name of the remote host to which you intend to connect. |
| port | The port number of the remote host to which you intend to connect. |
| 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. |
| auto xtd::net::sockets::tcp_client::end_connect | ( | xtd::sptr< xtd::iasync_result > | async_result | ) | -> void |
Ends a pending asynchronous connection attempt.
| result | An xtd::iasync_result object returned by a call to xtd::net::sockets::tcp_client::client::begin_connect. |
| argument_exception | async_result was not returned by a call to the xtd::net::sockets::socket::begin_connect 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. |
|
overridevirtualnoexcept |
Determines whether the specified object is equal to the current object.
| obj | The object to compare with the current object. |
true if the specified object is equal to the current object. otherwise, false. Reimplemented from xtd::object.
|
overridenoexcept |
Determines whether the specified object is equal to the current object.
| other | The object to compare with the current object. |
true if the specified object is equal to the current object. otherwise, false.
|
nodiscard |
Returns the xtd::net::sockets::network_stream used to send and receive data.
true value means that data has arrived from the remote host and is available for reading. In this case, std::iostream::read is guaranteed to complete immediately. If the remote host has shutdown its connection, std::iostream::read will immediately return with zero bytes.
|
nodiscardprotectednoexcept |
Gets a value that indicates whether a connection has been made.
true if the connection has been made; otherwise, false.
|
protectednoexcept |
Sets a value that indicates whether a connection has been made.
| value | true if the connection has been made; otherwise, false. |