xtd 0.2.0
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 tcp_client& operator =(const tcp_client&) = default;
84
86
96 size_t available() const;
97
112 tcp_client& client(const xtd::net::sockets::socket& value) noexcept;
113
122 bool connected() const noexcept;
123
141
177
183 bool no_delay() const;
190 tcp_client& no_delay(bool value);
191
199 size_t receive_buffer_size() const;
209
219
225 size_t send_buffer_size() const;
233
246
248
285 xtd::sptr<xtd::iasync_result> begin_connect(const xtd::string& host, uint16 port, xtd::async_callback callback, const xtd::any_object& state);
286
292 void close();
293
300 void connect(const xtd::net::ip_end_point& remote_end_point);
320 void connect(const xtd::string& hostname, uint16 port);
321
330
334 bool equals(const object& obj) const noexcept override;
338 bool equals(const tcp_client& other) const noexcept override;
339
347
348 protected:
350
355 bool active() const noexcept;
360 tcp_client& active(bool value) noexcept;
362
363 private:
364 friend tcp_listener;
365 explicit tcp_client(const xtd::net::sockets::socket& socket);
366
367 xtd::sptr<data> data_;
368 };
369 }
370 }
371}
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:61
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:22
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
size_t available() const
Gets the amount of data that has been received from the network and is available to be read.
xtd::sptr< xtd::iasync_result > begin_connect(const xtd::net::ip_address &address, uint16 port, xtd::async_callback callback, const xtd::any_object &state)
Begins an asynchronous request for a remote host connection. The remote host is specified by an xtd::...
void end_connect(xtd::sptr< xtd::iasync_result > async_result)
Ends a pending asynchronous connection attempt.
xtd::net::sockets::network_stream get_stream() const
Returns the xtd::net::sockets::network_stream used to send and receive data.
bool exclusive_address_use() const
Gets a bool value that specifies whether the xtd::net::sockets::tcp_client allows only one client to ...
int32 send_timeout() const
Gets the amount of time a xtd::net::sockets::tcp_client will wait for a send operation to complete su...
void close()
Disposes this xtd::net::sockets::tcp_client instance and requests that the underlying TCP connection ...
xtd::net::sockets::socket client() const noexcept
Gets 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...
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 a...
tcp_client()
Initializes a new instance of the xtd::net::sockets::tcp_client class.
size_t send_buffer_size() const
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.
bool active() const noexcept
Gets a value that indicates whether a connection has been made.
bool no_delay() const
Gets a value that disables a delay when send or receive buffers are not full.
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.
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...
int32 receive_timeout() const
Gets the amount of time a xtd::net::sockets::tcp_client will wait to receive data once a read operati...
bool equals(const object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
size_t receive_buffer_size() const
Gets the size of the receive buffer.
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:44
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
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.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:58
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.