DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
NetworkStream.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "Common.h"
9#include "System/IO/Stream.h"
11#include "System/SmartPointer.h"
12
13namespace DotNetDupe {
14 namespace System {
15 namespace Net {
16 namespace Sockets {
17
24 class NetworkStream : public IO::Stream {
25 public:
30
35 DOTNETDUPE_API NetworkStream(const SmartPointer<Socket>& socket, bool bOwnsSocket);
36
39
42 DOTNETDUPE_API bool CanRead() const override;
43
46 DOTNETDUPE_API bool CanSeek() const override;
47
50 DOTNETDUPE_API bool CanWrite() const override;
51
54 DOTNETDUPE_API long GetLength() const override;
55
58 DOTNETDUPE_API long GetPosition() const override;
59
62 DOTNETDUPE_API void SetPosition(long value) override;
63
65 DOTNETDUPE_API void Flush() override;
66
73 DOTNETDUPE_API int Read(char* buffer, int offset, int count) override;
74
77 DOTNETDUPE_API long Seek(long offset, int origin) override;
78
81 DOTNETDUPE_API void SetLength(long value) override;
82
88 DOTNETDUPE_API void Write(const char* buffer, int offset, int count) override;
89
91 DOTNETDUPE_API void Dispose() override;
92
94 DOTNETDUPE_API void Close();
95
96 private:
97 SmartPointer<Socket> m_pSocket;
98 bool m_bOwnsSocket;
99 bool m_bDisposed;
100 };
101
102 }
103 }
104 }
105}
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
Provides reference-counted and weak pointer memory management primitives ensuring zero raw ownership.
Implements the Berkeley sockets interface for network communications.
Provides a generic view of a sequence of bytes.
Definition Stream.h:16
bool CanWrite() const override
Gets a value that indicates whether the NetworkStream supports writing.
void Write(const char *buffer, int offset, int count) override
Writes data to the NetworkStream.
void SetPosition(long value) override
Sets the current position of the stream. Not supported.
bool CanSeek() const override
Gets a value that indicates whether the stream supports seeking. Always returns false.
int Read(char *buffer, int offset, int count) override
Reads data from the NetworkStream and stores it in the buffer.
void Dispose() override
Releases the unmanaged resources used by the NetworkStream.
NetworkStream(const SmartPointer< Socket > &socket)
Creates a new instance of the NetworkStream class for the specified Socket.
void SetLength(long value) override
Sets the length of the stream. Not supported.
bool CanRead() const override
Gets a value that indicates whether the NetworkStream supports reading.
long GetPosition() const override
Gets the current position within the stream. Not supported.
void Flush() override
Flushes data from the stream.
void Close()
Closes the NetworkStream and releases all resources.
long GetLength() const override
Gets the length of the data available on the stream. Not supported.
long Seek(long offset, int origin) override
Sets the current position of the stream to the given value. Not supported.
A unified smart pointer that supports both unique and shared ownership semantics.