xtd 1.0.0
Loading...
Searching...
No Matches
network_stream.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "socket.hpp"
7#include "../../io/stream.hpp"
8
10namespace xtd {
12 namespace net {
14 namespace sockets {
39 public:
41
47
53
64
68
70
74 [[nodiscard]] auto can_read() const noexcept -> bool override;
75
78 [[nodiscard]] auto can_seek() const noexcept -> bool override;
79
82 [[nodiscard]] auto can_timeout() const noexcept -> bool override;
83
86 [[nodiscard]] auto can_write() const noexcept -> bool override;
87
93 [[nodiscard]] virtual auto data_available() const -> bool;
94
97 [[nodiscard]] auto length() const -> xtd::usize override;
98
101 [[nodiscard]] auto position() const -> xtd::usize override;
104 auto position(xtd::usize value) -> void override;
105
108 [[nodiscard]] auto read_timeout() const -> xtd::int32 override;
111 auto read_timeout(xtd::int32 value) -> void override;
112
115 [[nodiscard]] auto write_timeout() const -> xtd::int32 override;
118 auto write_timeout(xtd::int32 value) -> void override;
119
123 [[nodiscard]] auto socket() const -> xtd::net::sockets::socket;
125
127
131 auto flush() -> void override;
132
133 using xtd::io::stream::read;
143 auto read(xtd::array<xtd::byte>& buffer, usize offset, usize count) -> xtd::usize override;
144
148 auto set_length(xtd::usize value) -> void override;
149
150 using xtd::io::stream::write;
163 auto write(const xtd::array<xtd::byte>& buffer, usize offset, usize count) -> void override;
165
166 private:
167 struct data {
170 bool owns_socket = false;
171 };
172 ptr<data> data_ = new_ptr<data>();
173 };
174 }
175 }
176}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Provides a generic view of a sequence of bytes. This is an abstract class.
Definition stream.hpp:39
stream()
Initializes a new instance of the xtd::io::stream class.
auto position() const -> xtd::usize override
Gets the current position within the stream.
auto read_timeout() const -> xtd::int32 override
Gets the amount of time that a read operation blocks waiting for data.
auto write_timeout() const -> xtd::int32 override
Gets the amount of time that a write operation blocks waiting for data.
auto can_seek() const noexcept -> bool override
Gets a value indicating whether the current stream supports seeking.
virtual auto data_available() const -> bool
Gets a value that indicates whether data is available on the xtd::net::sockets::network_stream to be ...
auto can_write() const noexcept -> bool override
Gets a value indicating whether the current stream supports writing.
network_stream(const xtd::net::sockets::socket &socket, xtd::io::file_access access)
Initializes a new instance of the network_stream class for the specified xtd::net::sockets::socket wi...
network_stream(const xtd::net::sockets::socket &socket)
Creates a new instance of the network_stream class for the specified xtd::net::sockets::socket.
network_stream(const xtd::net::sockets::socket &socket, bool owns_socket)
Initializes a new instance of the xtd::net::sockets::network_stream class for the specified xtd::net:...
auto can_timeout() const noexcept -> bool override
Indicates whether timeout properties are usable for xtd::net::sockets::network_stream.
auto length() const -> xtd::usize override
Gets the length of the stream in bytes.
auto socket() const -> xtd::net::sockets::socket
Gets the underlying xtd::net::sockets::socket.
network_stream(const xtd::net::sockets::socket &socket, xtd::io::file_access access, bool owns_socket)
Initializes a new instance of the network_stream class for the specified xtd::net::sockets::socket wi...
auto flush() -> void override
Flushes data from the stream. This method is reserved for future use.
auto write(const xtd::array< xtd::byte > &buffer, usize offset, usize count) -> void override
Writes a block of bytes to the current stream using data read from a buffer.
auto can_read() const noexcept -> bool override
Gets a value indicating whether the current stream supports reading.
auto set_length(xtd::usize value) -> void override
Sets the length of the current stream to the specified value.
auto read(xtd::array< xtd::byte > &buffer, usize offset, usize count) -> xtd::usize override
Reads a block of bytes from the current stream and writes the data to a buffer.
Implements the Berkeley sockets interface.
Definition socket.hpp:74
Contains xtd::io::file_access enum class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
file_access
Defines constants for read, write, or read/write access to a file. This enumeration has a flags attri...
Definition file_access.hpp:15
@ read_write
The file is a read_write file. The file is part of the operating read_write or is used exclusively by...
Definition file_access.hpp:21
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
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
Contains xtd::net::sockets::socket class.
Contains xtd::io::stream class.