xtd 0.2.0
Loading...
Searching...
No Matches
tcp_client.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "network_stream.hpp"
6#include "socket.hpp"
7#include "../ip_end_point.hpp"
9#include "../../object.hpp"
10#include "../../string.hpp"
11
13namespace xtd {
15 namespace net {
17 namespace sockets {
19 class tcp_listener;
21
48 class core_export_ tcp_client : public xtd::object, public xtd::iequatable<tcp_client> {
49 struct data;
50
51 public:
53
75 tcp_client(const xtd::string& hostname, uint16 port);
77
79 tcp_client(tcp_client&&) = default;
80 tcp_client(const tcp_client&) = default;
82 auto operator =(tcp_client&&) -> tcp_client& = default;
83 auto operator =(const tcp_client&) -> tcp_client& = default;
85
87
97 [[nodiscard]] auto available() const -> xtd::size;
98
105 [[nodiscard]] auto client() const noexcept -> xtd::net::sockets::socket;
113 auto client(const xtd::net::sockets::socket& value) noexcept -> tcp_client&;
114
123 [[nodiscard]] auto connected() const noexcept -> bool;
124
132 [[nodiscard]] auto exclusive_address_use() const -> bool;
141 auto exclusive_address_use(bool value) -> tcp_client&;
142
159 [[nodiscard]] auto linger_state() const -> xtd::net::sockets::linger_option;
178
184 [[nodiscard]] auto no_delay() const -> bool;
191 auto no_delay(bool value) -> tcp_client&;
192
200 [[nodiscard]] auto receive_buffer_size() const -> xtd::size;
210
214 [[nodiscard]] auto receive_timeout() const -> xtd::int32;
220
226 [[nodiscard]] auto send_buffer_size() const -> xtd::size;
234
239 [[nodiscard]] auto send_timeout() const -> xtd::int32;
247
249
262 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>;
274 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>;
286 auto begin_connect(const xtd::string& host, uint16 port, xtd::async_callback callback, const xtd::any_object& state) -> xtd::sptr<xtd::iasync_result>;
287
293 auto close() -> void;
294
301 auto connect(const xtd::net::ip_end_point& remote_end_point) -> void;
312 auto connect(const xtd::net::ip_address& ip_address, uint16 port) -> void;
321 auto connect(const xtd::string& hostname, uint16 port) -> void;
322
331
335 auto equals(const object& obj) const noexcept -> bool override;
339 auto equals(const tcp_client& other) const noexcept -> bool override;
340
346 [[nodiscard]] auto get_stream() const -> xtd::net::sockets::network_stream;
348
349 protected:
351
356 [[nodiscard]] auto active() const noexcept -> bool;
361 auto active(bool value) noexcept -> tcp_client&;
363
364 private:
365 friend tcp_listener;
366 explicit tcp_client(const xtd::net::sockets::socket& socket);
367
368 xtd::sptr<data> data_;
369 };
370 }
371 }
372}
Represent a polymorphic wrapper capable of holding any type.
Definition any_object.hpp:29
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents the status of an asynchronous operation.
Definition iasync_result.hpp:25
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Identifies a network address. This is an abstract class.
Definition end_point.hpp:27
Provides an Internet Protocol (IP) address.
Definition ip_address.hpp:42
Represents a network endpoint as an IP address and a port number.
Definition ip_end_point.hpp:28
Specifies whether a xtd::net::sockets::socket will remain connected after a call to the xtd::net::soc...
Definition linger_option.hpp:35
Provides the underlying stream of data for network access.
Definition network_stream.hpp:40
Implements the Berkeley sockets interface.
Definition socket.hpp:77
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 operati...
auto no_delay() const -> bool
Gets a value that disables a delay when send or receive buffers are not full.
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
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 su...
auto available() const -> xtd::size
Gets the amount of data that has been received from the network and is available to be read.
tcp_client()
Initializes a new instance of the xtd::net::sockets::tcp_client class.
auto end_connect(xtd::sptr< xtd::iasync_result > async_result) -> void
Ends a pending asynchronous connection attempt.
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::...
auto close() -> void
Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection ...
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 receive_buffer_size() const -> xtd::size
Gets the size of the receive buffer.
auto send_buffer_size() const -> xtd::size
Gets the size of the send buffer.
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 l...
tcp_client(xtd::net::sockets::address_family address_family)
The xtd::net::sockets::address_family of the IP protocol.
auto exclusive_address_use() const -> bool
Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to ...
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 a...
auto active() const noexcept -> bool
Gets a value that indicates whether a connection has been made.
auto client() const noexcept -> xtd::net::sockets::socket
Gets the underlying network xtd::net::sockets::socket.
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 p...
auto get_stream() const -> xtd::net::sockets::network_stream
Returns the xtd::net::sockets::network_stream used to send and receive data.
auto connected() const noexcept -> bool
Gets a value indicating whether the underlying xtd::net::sockets::socket for a xtd::net::sockets::tcp...
Listens for connections from TCP network clients.
Definition tcp_listener.hpp:40
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
xtd::delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.hpp:39
#define core_export_
Define shared library export.
Definition core_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.hpp:19
address_family
Specifies the addressing scheme that an instance of the xtd::net::sockets::socket class can use.
Definition address_family.hpp:30
@ host
The xtd::uri::host data.
Definition uri_components.hpp:23
@ port
The xtd::uri::port data.
Definition uri_components.hpp:25
@ other
The operating system is other.
Definition platform_id.hpp:60
Contains xtd::iequatable interface.
Contains xtd::net::ip_end_point class.
The xtd::net::sockets namespace provides a managed implementation of the Berkeley Sockets interface f...
Definition address_family.hpp:16
The xtd::net namespace provides a simple programming interface for many of the protocols used on netw...
Definition cookie_exception.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::net::sockets::network_stream class.
Contains xtd::object class.
Contains xtd::net::sockets::socket class.
Contains xtd::string alias.