xtd 0.2.0
Loading...
Searching...
No Matches
tcp_client.h
Go to the documentation of this file.
1
4#pragma once
5#include "network_stream.h"
6#include "socket.h"
7#include "../ip_end_point.h"
8#include "../../iequatable.h"
9#include "../../object.h"
10#include "../../string.h"
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
131 bool exclusive_address_use() const;
140 tcp_client& exclusive_address_use(bool value);
141
158 xtd::net::sockets::linger_option linger_state() const;
176 tcp_client& linger_state(const xtd::net::sockets::linger_option& value);
177
183 bool no_delay() const;
190 tcp_client& no_delay(bool value);
191
199 size_t receive_buffer_size() const;
208 tcp_client& receive_buffer_size(size_t value);
209
213 int32 receive_timeout() const;
218 tcp_client& receive_timeout(int32 value);
219
225 size_t send_buffer_size() const;
232 tcp_client& send_buffer_size(size_t value);
233
238 int32 send_timeout() const;
244 tcp_client& send_timeout(int32 value);
246
248
261 xtd::sptr<xtd::iasync_result> begin_connect(const xtd::net::ip_address& address, uint16 port, xtd::async_callback callback, const std::any& state);
273 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);
285 xtd::sptr<xtd::iasync_result> begin_connect(const xtd::string& host, uint16 port, xtd::async_callback callback, const std::any& state);
286
292 void close();
293
300 void connect(const xtd::net::ip_end_point& remote_end_point);
311 void connect(const xtd::net::ip_address& ip_address, uint16 port);
320 void connect(const xtd::string& hostname, uint16 port);
321
329 void end_connect(xtd::sptr<xtd::iasync_result> async_result);
330
331 using object::equals;
332 bool equals(const tcp_client& s) const noexcept override;
333
339 xtd::net::sockets::network_stream get_stream() const;
341
342 protected:
344
349 bool active() const noexcept;
354 tcp_client& active(bool value) noexcept;
356
357 private:
358 friend tcp_listener;
359 explicit tcp_client(const xtd::net::sockets::socket& socket);
360
361 xtd::sptr<data> data_;
362 };
363 }
364 }
365}
Represents text as a sequence of character units.
Definition basic_string.h:79
Represents the status of an asynchronous operation.
Definition iasync_result.h:25
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Identifies a network address. This is an abstract class.
Definition end_point.h:27
Provides an Internet Protocol (IP) address.
Definition ip_address.h:37
Represents a network endpoint as an IP address and a port number.
Definition ip_end_point.h:23
Specifies whether a xtd::net::sockets::socket will remain connected after a call to the xtd::net::soc...
Definition linger_option.h:34
Provides the underlying stream of data for network access.
Definition network_stream.h:37
Implements the Berkeley sockets interface.
Definition socket.h:74
Provides client connections for TCP network services.
Definition tcp_client.h:48
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()
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 l...
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 p...
Listens for connections from TCP network clients.
Definition tcp_listener.h:40
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
#define core_export_
Define shared library export.
Definition core_export.h:13
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
std::shared_ptr< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.h:25
uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.h:23
xtd::sptr< xtd::iasync_result > async_result
Represents the status of an asynchronous operation.
Definition async_result.h:19
delegate< void(async_result ar)> async_callback
References a method to be called when a corresponding asynchronous operation completes.
Definition delegate.h:36
address_family
Specifies the addressing scheme that an instance of the xtd::net::sockets::socket class can use.
Definition address_family.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10
Contains xtd::net::sockets::network_stream class.
Contains xtd::net::sockets::socket class.