xtd 0.2.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"
10
12namespace xtd {
14 namespace net {
16 namespace sockets {
41 public:
43
49
55
66
70
72
76 [[nodiscard]] auto can_read() const noexcept -> bool override;
77
80 [[nodiscard]] auto can_seek() const noexcept -> bool override;
81
84 [[nodiscard]] auto can_timeout() const noexcept -> bool override;
85
88 [[nodiscard]] auto can_write() const noexcept -> bool override;
89
95 [[nodiscard]] virtual auto data_available() const -> bool;
96
99 [[nodiscard]] auto length() const -> xtd::size override;
100
103 [[nodiscard]] auto position() const -> xtd::size override;
106 auto position(xtd::size value) -> void override;
107
110 [[nodiscard]] auto read_timeout() const -> xtd::int32 override;
113 auto read_timeout(xtd::int32 value) -> void override;
114
117 [[nodiscard]] auto write_timeout() const -> xtd::int32 override;
120 auto write_timeout(xtd::int32 value) -> void override;
121
125 [[nodiscard]] auto socket() const -> xtd::net::sockets::socket;
127
129
133 auto flush() -> void override;
134
135 using xtd::io::stream::read;
145 auto read(xtd::array<xtd::byte>& buffer, size offset, size count) -> xtd::size override;
146
150 auto set_length(xtd::size value) -> void override;
151
152 using xtd::io::stream::write;
165 auto write(const xtd::array<xtd::byte>& buffer, size offset, size count) -> void override;
167
168 private:
169 struct data {
172 bool owns_socket = false;
173 };
174 ptr<data> data_ = new_ptr<data>();
175 };
176 }
177 }
178}
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:40
stream()
Initializes a new instance of the xtd::io::stream class.
auto read_timeout() const -> xtd::int32 override
Gets the amount of time that a read operation blocks waiting for data.
auto read(xtd::array< xtd::byte > &buffer, size offset, size count) -> xtd::size override
Reads a block of bytes from the current stream and writes the data to a buffer.
auto write_timeout() const -> xtd::int32 override
Gets the amount of time that a write operation blocks waiting for data.
auto length() const -> xtd::size override
Gets the length of the stream in bytes.
auto can_seek() const noexcept -> bool override
Gets a value indicating whether the current stream supports seeking.
auto position() const -> xtd::size override
Gets the current position within the stream.
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 write(const xtd::array< xtd::byte > &buffer, size offset, size count) -> void override
Writes a block of bytes to the current stream using data read from a buffer.
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 set_length(xtd::size value) -> void override
Sets the length of the current stream to the specified value.
auto flush() -> void override
Flushes data from the stream. This method is reserved for future use.
auto can_read() const noexcept -> bool override
Gets a value indicating whether the current stream supports reading.
Implements the Berkeley sockets interface.
Definition socket.hpp:77
Contains xtd::io::file_access enum class.
#define core_export_
Define shared library export.
Definition core_export.hpp:13
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
ptr< type_t > new_ptr(args_t &&... args)
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::not_supported_exception exception.
Contains xtd::object_closed_exception exception.
Contains xtd::net::sockets::socket class.
Contains xtd::io::stream class.