Provides the underlying stream of data for network access.
true
for the value of the owns_socket parameter. Public Constructors | |
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::sockets::socket with the specified xtd::net::sockets::socket ownership. | |
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 with the specified access rights. | |
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 with the specified access rights and the specified xtd::net::sockets::socket ownership. | |
Public Properties | |
bool | can_read () const noexcept override |
Gets a value indicating whether the current stream supports reading. | |
bool | can_seek () const noexcept override |
Gets a value indicating whether the current stream supports seeking. | |
bool | can_timeout () const noexcept override |
Indicates whether timeout properties are usable for xtd::net::sockets::network_stream. | |
bool | can_write () const noexcept override |
Gets a value indicating whether the current stream supports writing. | |
virtual bool | data_available () const |
Gets a value that indicates whether data is available on the xtd::net::sockets::network_stream to be read. | |
xtd::size | length () const override |
Gets the length of the stream in bytes. | |
xtd::size | position () const override |
Gets the current position within the stream. | |
void | position (xtd::size value) override |
Sets the current position within the stream. | |
int32 | read_timeout () const override |
Gets the amount of time that a read operation blocks waiting for data. | |
void | read_timeout (int32 value) override |
Sets the amount of time that a read operation blocks waiting for data. | |
int32 | write_timeout () const override |
Gets the amount of time that a write operation blocks waiting for data. | |
void | write_timeout (int32 value) override |
Sets the amount of time that a write operation blocks waiting for data. | |
xtd::net::sockets::socket | socket () const |
Gets the underlying xtd::net::sockets::socket. | |
Public Methods | |
void | flush () override |
Flushes data from the stream. This method is reserved for future use. | |
xtd::size | read (xtd::array< xtd::byte > &buffer, size offset, size count) override |
Reads a block of bytes from the current stream and writes the data to a buffer. | |
void | set_length (xtd::size value) override |
Sets the length of the current stream to the specified value. | |
void | write (const xtd::array< xtd::byte > &buffer, size offset, size count) override |
Writes a block of bytes to the current stream using data read from a buffer. | |
Additional Inherited Members | |
![]() | |
static xtd::io::null_stream | null_stream |
A Stream with no backing store. | |
static constexpr int32 | eof |
Represnets an eof value. | |
![]() | |
virtual bool | is_closed () const noexcept |
Indicates if the stream is closed. | |
void | copy_to (std::ostream &destination) |
Reads the bytes from the current memory stream and writes them to another stream. | |
void | copy_to (std::ostream &destination, xtd::size buffer_size) |
Reads the bytes from the current memory stream and writes them to another stream, using a specified buffer size. | |
virtual xtd::size | read (xtd::span< xtd::byte > &buffer) |
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. | |
xtd::size | read_at_least (xtd::array< xtd::byte > &buffer, xtd::size minimum_bytes, bool throw_on_end_of_stream=true) |
Reads at least a minimum number of bytes from the current stream and advances the position within the stream by the number of bytes read. | |
virtual int32 | read_byte () |
void | read_exactly (xtd::array< xtd::byte > &buffer) |
Reads bytes from the current stream and advances the position within the stream until the buffer is filled. | |
void | read_exactly (xtd::array< xtd::byte > &buffer, xtd::size offset, xtd::size count) |
Reads count number of bytes from the current stream and advances the position within the stream. | |
virtual void | write (xtd::span< const xtd::byte > buffer) |
virtual void | write_byte (xtd::byte value) |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual xtd::string | to_string () const noexcept |
Returns a xtd::string that represents the current object. | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
![]() | |
stream () | |
Initializes a new instance of the xtd::io::stream class. | |
![]() | |
abstract_object ()=default | |
Initializes a new instance of the xtd::abstract_object class. | |
|
explicit |
Creates a new instance of the network_stream class for the specified xtd::net::sockets::socket.
socket | The xtd::net::sockets::socket that the xtd::net::sockets::network_stream will use to send and receive data. |
xtd::net::sockets::network_stream::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::sockets::socket with the specified xtd::net::sockets::socket ownership.
socket | The xtd::net::sockets::socket that the xtd::net::sockets::network_stream will use to send and receive data. |
owns_socket | Set to true to indicate that the xtd::net::sockets::network_stream will take ownership of the xtd::net::sockets::socket; otherwise, false . |
true
, the xtd::net::sockets::network_stream takes ownership of the underlying xtd::net::sockets::socket, and calling the close method also closes the underlying xtd::net::sockets::socket. xtd::net::sockets::network_stream::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 with the specified access rights.
socket | The xtd::net::sockets::socket that the xtd::net::sockets::network_stream will use to send and receive data. |
access | A bitwise combination of the xtd::io::file_access values that specify the type of access given to the xtd::net::sockets::network_stream over the provided xtd::net::sockets::socket. |
xtd::net::sockets::network_stream::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 with the specified access rights and the specified xtd::net::sockets::socket ownership.
socket | The xtd::net::sockets::socket that the xtd::net::sockets::network_stream will use to send and receive data. |
access | A bitwise combination of the xtd::io::file_access values that specify the type of access given to the xtd::net::sockets::network_stream over the provided xtd::net::sockets::socket. |
owns_socket | Set to true to indicate that the xtd::net::sockets::network_stream will take ownership of the xtd::net::sockets::socket; otherwise, false . |
|
overridevirtualnoexcept |
Gets a value indicating whether the current stream supports reading.
true
if the stream supports reading; otherwise, false
. Implements xtd::io::stream.
|
overridevirtualnoexcept |
Gets a value indicating whether the current stream supports seeking.
true
if the stream supports seeking; otherwise, false
. Implements xtd::io::stream.
|
overridevirtualnoexcept |
Indicates whether timeout properties are usable for xtd::net::sockets::network_stream.
true
in all cases. Reimplemented from xtd::io::stream.
|
overridevirtualnoexcept |
Gets a value indicating whether the current stream supports writing.
true
if the stream supports writing; otherwise, false
. Implements xtd::io::stream.
|
virtual |
Gets a value that indicates whether data is available on the xtd::net::sockets::network_stream to be read.
true
if data is available on the stream to be read; otherwise, false
. xtd::net::sockets::socket_exception | An error occurred when attempting to access the socket. |
xtd::object_closed_exception | The xtd::net::sockets::socket has been closed. |
true
, a call to std::iostream::read returns immediately. If the remote host shuts down or closes the connection, xtd::net::sockets::network_stream::data_available may throw a xtd::net::sockets::socket_exception.
|
overridevirtual |
Gets the length of the stream in bytes.
Implements xtd::io::stream.
|
overridevirtual |
Gets the current position within the stream.
Implements xtd::io::stream.
|
overridevirtual |
Sets the current position within the stream.
value | The current position within the stream. |
Implements xtd::io::stream.
|
overridevirtual |
Gets the amount of time that a read operation blocks waiting for data.
Reimplemented from xtd::io::stream.
|
overridevirtual |
Sets the amount of time that a read operation blocks waiting for data.
value | A xtd::int32 that specifies the amount of time, in milliseconds, that will elapse before a read operation fails. The default value, xtd::threading::timeout::infinite, specifies that the read operation does not time out. |
Reimplemented from xtd::io::stream.
|
overridevirtual |
Gets the amount of time that a write operation blocks waiting for data.
Reimplemented from xtd::io::stream.
|
overridevirtual |
Sets the amount of time that a write operation blocks waiting for data.
value | A xtd::int32 that specifies the amount of time, in milliseconds, that will elapse before a read operation fails. The default value, xtd::threading::timeout::infinite, specifies that the read operation does not time out. |
Reimplemented from xtd::io::stream.
xtd::net::sockets::socket xtd::net::sockets::network_stream::socket | ( | ) | const |
Gets the underlying xtd::net::sockets::socket.
|
overridevirtual |
Flushes data from the stream. This method is reserved for future use.
Implements xtd::io::stream.
|
overridevirtual |
Reads a block of bytes from the current stream and writes the data to a buffer.
buffer | When this method returns, contains the specified byte array with the values between offset and (offset + count - 1) replaced by the characters read from the current stream. |
offset | The zero-based byte offset in buffer at which to begin storing data from the current stream. |
count | The maximum number of bytes to read. |
offset
parameter gives the offset of the first byte in buffer
to which data from the current stream is written. The count
parameter gives the maximum number of bytes to read from the current stream. The returned value is the actual number of bytes read, or zero if the end of the stream is reached. read
method will return zero only if the end of the stream is reached. In all other cases, read
always reads at least one byte from the stream before returning. By definition, if no data is available from the stream upon a call to read
, the read
method returns zero (the end of the stream is reached automatically). An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached. Implements xtd::io::stream.
|
overridevirtual |
Sets the length of the current stream to the specified value.
value | The value at which to set the length. |
Implements xtd::io::stream.
|
overridevirtual |
Writes a block of bytes to the current stream using data read from a buffer.
buffer | The buffer to write data from. |
offset | The zero-based byte offset in buffer at which to begin copying bytes to the current stream. |
count | The maximum number of bytes to write. |
offset
parameter gives the offset of the first byte in buffer
to write from, and the count
parameter gives the number of bytes to write. If the write operation is successful, the current position within the stream is advanced by the number of bytes written. If an exception occurs, the current position within the stream is unchanged. memory_stream
constructed with a byte[] parameter, write operations at the end of a memory_stream
expand the memory_stream
. Implements xtd::io::stream.