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 | |
| size_t | available () const | 
| Gets the amount of data that has been received from the network and is available to be read.   | |
| xtd::net::sockets::socket | client () const noexcept | 
| Gets the underlying network xtd::net::sockets::socket.   | |
| tcp_client & | client (const xtd::net::sockets::socket &value) noexcept | 
| Sets the underlying network xtd::net::sockets::socket.   | |
| bool | connected () const noexcept | 
| Gets a value indicating whether the underlying xtd::net::sockets::socket for a xtd::net::sockets::tcp_client is connected to a remote host.   | |
| bool | exclusive_address_use () const | 
| Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port.   | |
| tcp_client & | exclusive_address_use (bool value) | 
| Sets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port.   | |
| xtd::net::sockets::linger_option | linger_state () const | 
| Gets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data.   | |
| tcp_client & | linger_state (const xtd::net::sockets::linger_option &value) | 
| Sets a value that specifies whether the xtd::net::sockets::socket will delay closing a socket in an attempt to send all pending data.   | |
| bool | no_delay () const | 
| Gets a value that disables a delay when send or receive buffers are not full.   | |
| tcp_client & | no_delay (bool value) | 
| Sets a value that disables a delay when send or receive buffers are not full.   | |
| size_t | receive_buffer_size () const | 
| Gets the size of the receive buffer.   | |
| tcp_client & | receive_buffer_size (size_t value) | 
| Sets the size of the receive buffer.   | |
| int32 | receive_timeout () const | 
| Gets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated.   | |
| tcp_client & | receive_timeout (int32 value) | 
| Sets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated.   | |
| size_t | send_buffer_size () const | 
| Gets the size of the send buffer.   | |
| tcp_client & | send_buffer_size (size_t value) | 
| Sets the size of the send buffer.   | |
| int32 | send_timeout () const | 
| Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully.   | |
| tcp_client & | send_timeout (int32 value) | 
| Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully.   | |
Public Methods | |
| xtd::sptr< xtd::iasync_result > | begin_connect (const xtd::net::ip_address &address, uint16 port, xtd::async_callback callback, const std::any &state) | 
| 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).   | |
| xtd::sptr< xtd::iasync_result > | begin_connect (const std::vector< xtd::net::ip_address > &addresses, uint16 port, xtd::async_callback callback, const std::any &state) | 
| 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).   | |
| xtd::sptr< xtd::iasync_result > | begin_connect (const xtd::string &host, uint16 port, xtd::async_callback callback, const std::any &state) | 
| 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).   | |
| void | close () | 
| Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection be closed.   | |
| void | connect (const xtd::net::ip_end_point &remote_end_point) | 
| Connects the client to a remote TCP host using the specified remote network endpoint.   | |
| void | connect (const xtd::net::ip_address &ip_address, uint16 port) | 
| Connects the client to a remote TCP host using the specified IP address and port number.   | |
| void | connect (const xtd::string &hostname, uint16 port) | 
| Connects the client to the specified port on the specified host.   | |
| void | end_connect (xtd::sptr< xtd::iasync_result > async_result) | 
| Ends a pending asynchronous connection attempt.   | |
| bool | equals (const tcp_client &s) const noexcept override | 
| xtd::net::sockets::network_stream | get_stream () const | 
| Returns the xtd::net::sockets::network_stream used to send and receive data.   | |
| virtual bool | equals (const object &obj) const noexcept | 
| Determines whether the specified object is equal to the current object.   | |
| template<typename object_a_t , typename 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.   | |
Protected Properties | |
| bool | active () const noexcept | 
| Gets a value that indicates whether a connection has been made.   | |
| tcp_client & | active (bool value) noexcept | 
| Sets a value that indicates whether a connection has been made.   | |
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<typename 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_client > | |
| virtual bool | equals (const tcp_client &) 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<typename object_a_t , typename 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<typename object_a_t , typename 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. | 
| size_t xtd::net::sockets::tcp_client::available | ( | ) | const | 
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. | 
      
  | 
  noexcept | 
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 | 
      
  | 
  noexcept | 
Gets a value indicating whether the underlying xtd::net::sockets::socket for a xtd::net::sockets::tcp_client is connected to a remote host.
| bool xtd::net::sockets::tcp_client::exclusive_address_use | ( | ) | const | 
Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to use a port.
| 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. | 
| tcp_client & xtd::net::sockets::tcp_client::exclusive_address_use | ( | bool | value | ) | 
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. | 
| xtd::net::sockets::linger_option xtd::net::sockets::tcp_client::linger_state | ( | ) | const | 
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. | 
| tcp_client & xtd::net::sockets::tcp_client::linger_state | ( | const xtd::net::sockets::linger_option & | value | ) | 
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. | 
| bool xtd::net::sockets::tcp_client::no_delay | ( | ) | const | 
Gets a value that disables a delay when send or receive buffers are not full.
| 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. | 
| tcp_client & xtd::net::sockets::tcp_client::no_delay | ( | bool | value | ) | 
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. | 
| size_t xtd::net::sockets::tcp_client::receive_buffer_size | ( | ) | const | 
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. | 
| tcp_client & xtd::net::sockets::tcp_client::receive_buffer_size | ( | size_t | value | ) | 
Sets the size of the receive buffer.
| value | A size_t 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. | 
| int32 xtd::net::sockets::tcp_client::receive_timeout | ( | ) | const | 
Gets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operation is initiated.
| tcp_client & xtd::net::sockets::tcp_client::receive_timeout | ( | int32 | value | ) | 
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. | 
| size_t xtd::net::sockets::tcp_client::send_buffer_size | ( | ) | const | 
Gets the size of the send buffer.
| tcp_client & xtd::net::sockets::tcp_client::send_buffer_size | ( | size_t | value | ) | 
Sets the size of the send buffer.
| value | The size of the send buffer, in bytes. The default value is 8192 bytes. | 
| int32 xtd::net::sockets::tcp_client::send_timeout | ( | ) | const | 
Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete successfully.
| tcp_client & xtd::net::sockets::tcp_client::send_timeout | ( | int32 | value | ) | 
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. | 
| xtd::sptr< xtd::iasync_result > xtd::net::sockets::tcp_client::begin_connect | ( | const xtd::net::ip_address & | address, | 
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const std::any & | state | ||
| ) | 
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. | 
| xtd::sptr< xtd::iasync_result > xtd::net::sockets::tcp_client::begin_connect | ( | const std::vector< xtd::net::ip_address > & | addresses, | 
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const std::any & | state | ||
| ) | 
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. | 
| xtd::sptr< xtd::iasync_result > xtd::net::sockets::tcp_client::begin_connect | ( | const xtd::string & | host, | 
| uint16 | port, | ||
| xtd::async_callback | callback, | ||
| const std::any & | state | ||
| ) | 
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. | 
| void xtd::net::sockets::tcp_client::close | ( | ) | 
Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection be closed.
| void xtd::net::sockets::tcp_client::connect | ( | const xtd::net::ip_end_point & | remote_end_point | ) | 
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. | 
| void xtd::net::sockets::tcp_client::connect | ( | const xtd::net::ip_address & | ip_address, | 
| uint16 | port | ||
| ) | 
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. | 
| void xtd::net::sockets::tcp_client::connect | ( | const xtd::string & | hostname, | 
| uint16 | port | ||
| ) | 
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. | 
| void xtd::net::sockets::tcp_client::end_connect | ( | xtd::sptr< xtd::iasync_result > | async_result | ) | 
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. | 
| xtd::net::sockets::network_stream xtd::net::sockets::tcp_client::get_stream | ( | ) | const | 
Returns the xtd::net::sockets::network_stream used to send and receive data.
      
  | 
  protectednoexcept | 
Gets a value that indicates whether a connection has been made.
      
  | 
  protectednoexcept | 
Sets a value that indicates whether a connection has been made.
| value | true if the connection has been made; otherwise, false. | 
      
  | 
  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. |