From a4568be6fa847b7bc64d826adb51cdefbab925ef Mon Sep 17 00:00:00 2001 From: Reece Date: Fri, 1 Apr 2022 04:38:10 +0100 Subject: [PATCH] [*] Kill net. Branching... --- Include/Aurora/IO/Net/Net.hpp | 355 +++++++++++++----------- Source/Entrypoint.cpp | 6 +- Source/IO/Net/BaseChannel.cpp | 84 ------ Source/IO/Net/BaseChannel.hpp | 119 -------- Source/IO/Net/BaseLocalClient.cpp | 24 -- Source/IO/Net/BaseLocalClient.hpp | 25 -- Source/IO/Net/BaseNetworkInterface.cpp | 38 --- Source/IO/Net/BaseNetworkInterface.hpp | 22 -- Source/IO/Net/BaseServer.cpp | 45 --- Source/IO/Net/BaseServer.hpp | 60 ---- Source/IO/Net/BaseSocket.cpp | 43 --- Source/IO/Net/BaseSocket.hpp | 95 ------- Source/IO/Net/HelloNet.Win32.cpp | 22 -- Source/IO/Net/HelloNet.Win32.hpp | 14 - Source/IO/Net/IPAddress.cpp | 64 ----- Source/IO/Net/IPAddress.hpp | 13 - Source/IO/Net/Net.cpp | 14 - Source/IO/Net/Net.hpp | 22 -- Source/IO/Net/NetworkingPool.cpp | 68 ----- Source/IO/Net/NetworkingPool.hpp | 39 --- Source/IO/Net/PlatformChannel.Win32.cpp | 15 - Source/IO/Net/PlatformChannel.hpp | 28 -- Source/IO/Net/PlatformSocket.Win32.cpp | 52 ---- Source/IO/Net/PlatformSocket.Win32.hpp | 25 -- Source/IO/Net/PlatformSocket.hpp | 17 -- Source/IO/Net/SocketFactory.cpp | 33 --- Source/IO/Net/SocketFactory.hpp | 20 -- Source/IO/Net/SocketStatAverageBps.hpp | 88 ------ Source/IO/Net/SocketStatChannel.hpp | 36 --- Source/IO/Net/WorkPoolGroup.cpp | 19 -- Source/IO/Net/WorkPoolGroup.hpp | 13 - Source/IO/Net/WorkRange.cpp | 19 -- Source/IO/Net/WorkRange.hpp | 13 - 33 files changed, 193 insertions(+), 1357 deletions(-) delete mode 100644 Source/IO/Net/BaseChannel.cpp delete mode 100644 Source/IO/Net/BaseChannel.hpp delete mode 100644 Source/IO/Net/BaseLocalClient.cpp delete mode 100644 Source/IO/Net/BaseLocalClient.hpp delete mode 100644 Source/IO/Net/BaseNetworkInterface.cpp delete mode 100644 Source/IO/Net/BaseNetworkInterface.hpp delete mode 100644 Source/IO/Net/BaseServer.cpp delete mode 100644 Source/IO/Net/BaseServer.hpp delete mode 100644 Source/IO/Net/BaseSocket.cpp delete mode 100644 Source/IO/Net/BaseSocket.hpp delete mode 100644 Source/IO/Net/HelloNet.Win32.cpp delete mode 100644 Source/IO/Net/HelloNet.Win32.hpp delete mode 100644 Source/IO/Net/IPAddress.cpp delete mode 100644 Source/IO/Net/IPAddress.hpp delete mode 100644 Source/IO/Net/Net.cpp delete mode 100644 Source/IO/Net/Net.hpp delete mode 100644 Source/IO/Net/NetworkingPool.cpp delete mode 100644 Source/IO/Net/NetworkingPool.hpp delete mode 100644 Source/IO/Net/PlatformChannel.Win32.cpp delete mode 100644 Source/IO/Net/PlatformChannel.hpp delete mode 100644 Source/IO/Net/PlatformSocket.Win32.cpp delete mode 100644 Source/IO/Net/PlatformSocket.Win32.hpp delete mode 100644 Source/IO/Net/PlatformSocket.hpp delete mode 100644 Source/IO/Net/SocketFactory.cpp delete mode 100644 Source/IO/Net/SocketFactory.hpp delete mode 100644 Source/IO/Net/SocketStatAverageBps.hpp delete mode 100644 Source/IO/Net/SocketStatChannel.hpp delete mode 100644 Source/IO/Net/WorkPoolGroup.cpp delete mode 100644 Source/IO/Net/WorkPoolGroup.hpp delete mode 100644 Source/IO/Net/WorkRange.cpp delete mode 100644 Source/IO/Net/WorkRange.hpp diff --git a/Include/Aurora/IO/Net/Net.hpp b/Include/Aurora/IO/Net/Net.hpp index 3a2216bb..ae298102 100644 --- a/Include/Aurora/IO/Net/Net.hpp +++ b/Include/Aurora/IO/Net/Net.hpp @@ -33,6 +33,36 @@ namespace Aurora::IO::Net eIPProtocolV6 )); + AUE_DEFINE(ESocketInfo, ( + eByDns, + eByEndpoint + )); + + AUE_DEFINE(ENetworkError, ( + eResourceConstraint, + eIllegalArgument, + ePermissionDenied, + eSocketBufferOverflow, + eAsyncError, + eNoNetwork, + eUnreachable, + eTimeout, + eSocketClosed, + eConnectionReset, + eEndpointRefused, + eServiceRefused, + eServiceTaken, + eUnknown + )); + + AUE_DEFINE(EHandleErrorClass, ( + ePinError, + eUserDeny, + eBrokenPacket, + eInvalidCipher, + eBadCert + )); + struct AUKN_SYM IPAddress { EIPProtocol ip; @@ -42,44 +72,39 @@ namespace Aurora::IO::Net AuUInt16 v6[8]; }; - IPAddress(); - IPAddress(const AuString &parse); - - AuString ToString() const; - bool IsValid() const; - - - inline operator bool() const - { - return IsValid(); - } - - inline bool operator ==(const IPAddress &cmp) const - { - if (cmp.ip != this->ip) return false; - - if (cmp.ip == EIPProtocol::eIPProtocolV4) - { - return AuMemcmp(cmp.v4, this->v4, sizeof(this->v4)) == 0; - } - else - { - return AuMemcmp(cmp.v6, this->v6, sizeof(this->v6)) == 0; - } - } + //IPAddress(); + //IPAddress(const AuString &parse); + // + //AuString ToString() const; + //bool IsValid() const; + // + // + //inline operator bool() const + //{ + // return IsValid(); + //} + // + //inline bool operator ==(const IPAddress &cmp) const + //{ + // if (cmp.ip != this->ip) return false; + // + // if (cmp.ip == EIPProtocol::eIPProtocolV4) + // { + // return AuMemcmp(cmp.v4, this->v4, sizeof(this->v4)) == 0; + // } + // else + // { + // return AuMemcmp(cmp.v6, this->v6, sizeof(this->v6)) == 0; + // } + //} }; - AUE_DEFINE(ESocketInfo, ( - eByDns, - eByEndpoint - )); - struct SocketHostName { - SocketHostName(const AuString &name) : info(ESocketInfo::eByDns), hostname(name), address() + inline SocketHostName(const AuString &name) : info(ESocketInfo::eByDns), hostname(name), address() {} - SocketHostName(const IPAddress &endpoint) : info(ESocketInfo::eByEndpoint), address(endpoint), hostname() + inline SocketHostName(const IPAddress &endpoint) : info(ESocketInfo::eByEndpoint), address(endpoint), hostname() {} const ESocketInfo info; @@ -91,7 +116,7 @@ namespace Aurora::IO::Net if (cmp.info != this->info) return false; if (cmp.info == ESocketInfo::eByEndpoint) { - return cmp.address == this->address; + return false;// cmp.address == this->address; } else { @@ -103,7 +128,8 @@ namespace Aurora::IO::Net struct IPEndpoint { IPAddress ip; - AuUInt16 port; + AuUInt16 port {0}; + AuUInt32 ipv6Scope {0}; AuUInt8 hint[32] {0}; }; @@ -123,14 +149,12 @@ namespace Aurora::IO::Net virtual AuSPtr GetCertificate() = 0; }; - AUE_DEFINE(EHandleErrorClass, ( - ePinError, - eUserDeny, - eBrokenPacket, - eInvalidCipher, - eBadCert - )); - + struct NetError + { + ENetworkError error { ENetworkError::kEnumInvalid }; + AuUInt osError; + }; + struct TLSHandshakeError { EHandleErrorClass error; @@ -138,6 +162,11 @@ namespace Aurora::IO::Net AuString message; }; + + AUKN_INTERFACE(INetTask, + AUI_METHOD(void, DoWork, ()) + ); + AUKN_INTERFACE(IClientSubscriber, // AUI_METHOD(void, OnServerConnectSuccess, (const AuSPtr &, socket)), @@ -175,7 +204,7 @@ namespace Aurora::IO::Net // TODO: We should introduce another std:: customer overloadable type reproducing hardcoded ascii and an int, basically std::error_code // Maybe AuErrorCode = [std::, my_fav_stl::]error_code // AuError = something more flexable - using Error_t = std::error_code; + using Error_t = NetError; struct IBasicSocketPrivateContext { @@ -197,44 +226,85 @@ namespace Aurora::IO::Net AuUInt32 uptimeMs; AuUInt64 bandwidthCost; + AuUInt32 blamedConnectTimeMS; + AuUInt32 totalConnectTimeMS; + SocketStatStream rx; SocketStatStream rt; }; - enum class EUnderlyingModel - { - eAsync, - eBlocking - }; - struct IBasicSocket { + /** + * @brief Is socket still established, listening, or otherwise capable of performing non-recv operations? + * @return + */ virtual bool IsActive() = 0; + + /** + * @brief Returns the last relevant error + * @return + */ virtual Error_t GetLastError() = 0; + + /** + * @brief Initiates the shutdown sequence on the socket + */ virtual void Shutdown() = 0; + + /** + * @brief Exchanges the user-provided private context + * @param newContext + * @return + */ virtual AuSPtr SetContext(const AuSPtr &newContext) = 0; + + /** + * @brief Returns a user-provided private context + * @return + */ virtual AuSPtr GetContext() = 0; + + /** + * @brief Returns local endpoint of the socket once established/listening + * @param out + * @return + */ virtual bool GetLocalEndpoint(ConnectionEndpoint &out) = 0; + + /** + * @brief Returns performance stats of the socket + * @return + */ virtual SocketStat GetStats() = 0; - virtual EUnderlyingModel GetThreadModel() = 0; + + + /** + * @brief Schedule work on the thread assigned to the socket + * @param task + * @return + */ + virtual bool DoWork(AuSPtr task) = 0; }; AUKN_INTERFACE(ISocketSubmissionComplete, AUI_METHOD(void, OnWriteFinished, (AuUInt, fence)) ); + struct OverlappedOperation + { + AuUInt fence; + AuSPtr callback; + }; + struct StreamConfig { - bool enableBufferedInput {true}; - bool enableBufferedOutput {false}; + AuUInt32 recvRingBufferLength; + }; - // 30000 * (4096 * 10) / 1024 / 1024 / 1024 - // = 1.1GB per ~1/2 of 2^16 - // Plenty of overhead for cpu blts to go brr without becoming - // cpu bound. If you're expecting 30k connections, you can - // lose 1GB to our extended seak interface by default - AuUInt32 bufferedReadSize {4096 * 10}; // see: enableBufferedInput - AuUInt32 bufferedWriteSize {4096 * 10}; // see: enableBufferedOutput + struct SocketConfig + { + StreamConfig stream; }; struct ISocketChannel @@ -267,22 +337,13 @@ namespace Aurora::IO::Net // If you are under the callstack of a HasXXXHasData callback, you are guaranteed (bufferedReadSize - streamPosition - streamRemaining) bytes backwards // virtual bool SeekAsync(int signedDistanceFromCur = 0) = 0; - - // When BufferInputStreamAdhoc is called with false / in the default condition, read sync will be constrained by the async buffer - // When BufferInputStreamAdhoc is called with true, you will block until you can get the requested data (all of it if, all = true; any of it, all = false) - virtual bool ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all = true) = 0; - + // Writes max(cumulative memory.length per frame, (enableBufferedInput ? bufferedWriteSize : os page allowance)) to the sockets asynchronous stream // Returns false when no data whatsoever was written, generic error condition // Returns true when some data was collected, regardless of any errors that may have arose (defer to IServerSubscriber::OnClientError, IClientSubscriber::OnSocketError for error handling) - virtual bool WriteAsync(const Memory::MemoryViewStreamRead &memory) = 0; + virtual bool WriteAsync(const AuSPtr &memory, const OverlappedOperation &fence) = 0; + virtual bool WriteAsync(const AuSPtr &memory) = 0; - // Alternative WriteAsync method that calls a submission notification callback on flush on the dispatching thread - virtual bool WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr &input) = 0; - - // When BufferInputStreamAdhoc is called with false / in the default condition, read sync will be constrained by the async buffer - // When BufferInputStreamAdhoc is called with true, you will block until you can get the requested data (all of it if, all = true; any of it, all = false) - virtual bool WriteSync(const Memory::MemoryViewStreamRead &memory) = 0; /** * Sets the internal application buffer size @@ -293,60 +354,23 @@ namespace Aurora::IO::Net virtual bool SetInternalInputRingBuffer(AuUInt bytes) = 0; + #if 0 /** * Defines the maximum amount of bytes each recieve frame can ingest */ - virtual void SetRecvLength(AuUInt32 length) = 0; - virtual AuUInt32 GetRecvLength() = 0; - - /** - * Enable ad-hoc input buffer ingestion into our internal buffer - * Only use when PumpRead will not suffice by design (ie: sync apps) - * - * When set to true, there is nothing preventing you from consuming a - * DoS-worthy amount of bytes from the stream per frame - * - * This does not disable enableBufferedInput, it merely allows you - * to read beyond enableBufferedInput/bufferedReadSize by accessing - * the os stream page or hitting the network device inline - * - * There may be a performance bottleneck and/or gain depending on your - * circumstances - * - * During high bandwidth transfers, you should set this to true - * - * Default: false (0) - */ - virtual void BufferInputStreamAdhoc(bool value) = 0; - - virtual void ConfigureHasDataCallback(bool enabled) = 0; - - virtual void ReconfigureStreams(const StreamConfig &config) = 0; + virtual void SetRecvPerFrameLength(AuUInt32 length) = 0; + virtual AuUInt32 GetRecvPerFrameLength() = 0; + #endif }; - struct IBasicSocketThreaded : public IBasicSocket - { - virtual bool PumpRead() = 0; - virtual bool PumpWrite() = 0; - virtual bool Pump() = 0; - virtual void Run(int idx, AuUInt32 timeout) = 0; - }; - - struct ISocket : public IBasicSocketThreaded, public ISocketChannel + struct ISocket : public IBasicSocket, public ISocketChannel { - virtual bool GetRemoteEndpoint(ConnectionEndpoint &out) = 0; + virtual bool GetRemoteEndpoint(ConnectionEndpoint &out) = 0; }; struct ILocalClientSocket : public ISocket { - // Connects to the endpoint defined in the ClientConfig - // Completion will be notified by the following callbacks; - // IClientSubscriber::OnServerConnectSuccess, - // IClientSubscriber::OnServerConnectFailed - // returns true on success - virtual bool Connect() = 0; - // Completion will be notified by the following callbacks; // IClientSubscriber::OnServerConnectSuccess, // IClientSubscriber::OnServerConnectFailed @@ -361,11 +385,6 @@ namespace Aurora::IO::Net AuSPtr socket; }; - struct SocketConfig - { - StreamConfig stream; - }; - struct ServerInfo { ConnectionEndpoint listen; @@ -382,9 +401,7 @@ namespace Aurora::IO::Net struct ClientConfig : SocketConfig { - SocketHostName socket; - //AuString service; - AuUInt16 port; + IPEndpoint endpoint; bool enableHasDataCallback {true}; AuSPtr clientSubscriber; }; @@ -394,23 +411,13 @@ namespace Aurora::IO::Net AuSPtr clientSubscriber; }; - struct IServer : public IBasicSocketThreaded + struct IServer : public IBasicSocket { - virtual bool GetLocalEndpoint(ConnectionEndpoint &out) = 0; - virtual void GetClients(AuList> &clients) = 0; + virtual void GetClients(AuList> &clients) = 0; virtual bool Listen() = 0; virtual void ReconfigureDefaultStream(const StreamConfig &config) = 0; }; - struct ISocketFactory - { - virtual bool NewServer(const ServerInfo &listen, AuSPtr &out) = 0; - virtual bool NewTlsServer(const TLSServerInfo &keys, AuSPtr &out) = 0; - - virtual bool NewClient(const ClientConfig &info, AuSPtr &out) = 0; - virtual bool NewTlsClient(const TLSClientConfig &info, AuSPtr &out) = 0; - }; - struct ServiceEndpoint { ETransportProtocol protocol; @@ -418,16 +425,6 @@ namespace Aurora::IO::Net AuString service; }; - struct INetworkInterface - { - virtual AuList ResolveSocketSync(const SocketHostName &hostname, AuUInt16 port) = 0; - virtual AuList ResolveServiceSync(const ServiceEndpoint &service) = 0; - - virtual bool SendDatagramAsync(const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) = 0; - virtual bool SendDatagramAsync(const AuSPtr &datagramServer, const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) = 0; - - virtual AuSPtr GetSocketFactory() = 0; - }; struct AUKN_SYM WorkRange { @@ -449,30 +446,25 @@ namespace Aurora::IO::Net struct INetworkingPool { - // A: - virtual AuUInt32 Pump(AuUInt8 workerId) = 0; + // A: Manual poll + virtual AuUInt32 PollWorker(AuUInt8 workerId, bool clientBound, bool writeBound) = 0; + virtual bool RunWorkerFrame(AuUInt8 workerId, AuUInt32 timeout) = 0; - // B: - virtual AuUInt32 PumpRead(AuUInt8 workerId) = 0; - virtual AuUInt32 PumpWrite(AuUInt8 workerId) = 0; + // B: Ad-hoc loop-source IO + virtual bool BeginReadPollingOnWorkQueues(const WorkPoolGroup &workGroup) = 0; + virtual bool BeginSubmissionsOnOnWorkQueues(const WorkPoolGroup &workGroup) = 0; + virtual void StopPollingOnWorkQueues() = 0; - // C: - virtual AuUInt32 PollWorker(AuUInt8 workerId) = 0; - virtual AuUInt32 RunWorker(AuUInt8 workerId, AuUInt32 timeout) = 0; + // C: Fixed timestep IO + virtual bool BeginNetworkFrequency(AuUInt32 MSTimeStep, const WorkPoolGroup &workGroup) = 0; + virtual void StopNetworkFrequency() = 0; - // D: - virtual bool BeginReadPollingOnWorkQueues(const WorkPoolGroup &workGroup) = 0; - virtual bool BeginSubmissionsOnOnWorkQueues(const WorkPoolGroup &workGroup) = 0; - virtual void StopPollingOnWorkQueues() = 0; + // Submit to worker thread + virtual bool DoWork(AuUInt8 index, AuSPtr task) = 0; + virtual bool DoWork(AuSPtr task) = 0; - // E: - // .. - - virtual AuUInt8 GetWorkers() = 0; - - virtual AuSPtr GetNetworkInterface() = 0; - - virtual void Shutdown() = 0; + // Worker count + virtual AuUInt8 GetWorkers() = 0; }; struct NetworkPool @@ -480,5 +472,38 @@ namespace Aurora::IO::Net AuUInt8 workers {1}; }; - AUKN_SHARED_API(CreateNetworkPool, INetworkingPool, const NetworkPool & meta); + + struct INetworkDatagramService + { + virtual bool SendDatagramAsync(const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) = 0; + virtual bool SendDatagramAsync(const AuSPtr &datagramServer, const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) = 0; + }; + + struct INetworkBasicResolve + { + virtual AuList ResolveSocketSync(const SocketHostName &hostname, AuUInt16 port) = 0; + virtual AuList ResolveServiceSync(const ServiceEndpoint &service) = 0; + }; + + struct ISocketService + { + virtual bool NewServer(const ServerInfo &listen, AuSPtr &out) = 0; + virtual bool NewTlsServer(const TLSServerInfo &keys, AuSPtr &out) = 0; + + virtual bool NewClient(const ClientConfig &info, AuSPtr &out) = 0; + virtual bool NewTlsClient(const TLSClientConfig &info, AuSPtr &out) = 0; + }; + + struct INetworkInterface + { + virtual INetworkingPool *ToPool() = 0; + + virtual INetworkDatagramService *ToDatagramService() = 0; + virtual INetworkBasicResolve * ToResolveService() = 0; + virtual ISocketService * ToSocketService() = 0; + + virtual void Shutdown() = 0; + }; + + AUKN_SHARED_API(CreateNetworkPool, INetworkInterface, const NetworkPool & meta); } \ No newline at end of file diff --git a/Source/Entrypoint.cpp b/Source/Entrypoint.cpp index 226ae0c4..b1b25c10 100644 --- a/Source/Entrypoint.cpp +++ b/Source/Entrypoint.cpp @@ -25,7 +25,7 @@ #if defined(AURORA_PLATFORM_WIN32) #include "Extensions/Win32/DarkTheme.hpp" #endif -#include "IO/Net/Net.hpp" +//#include "IO/Net/Net.hpp" #include "Process/ProcessMap.hpp" #include "Exit/Exit.hpp" #include "CmdLine/CmdLine.hpp" @@ -48,7 +48,7 @@ static void Init() Aurora::Console::Init2(); Aurora::HWInfo::Init(); Aurora::Telemetry::Init(); - Aurora::IO::Net::InitNetworking(); + //Aurora::IO::Net::InitNetworking(); Aurora::Grug::InitGrug(); Aurora::Debug::InitDebug(); Aurora::Locale::Init(); @@ -71,7 +71,7 @@ static void Deinit() Aurora::Async::ShutdownAsync(); Aurora::Grug::DeinitGrug(); Aurora::Console::Exit(); - Aurora::IO::Net::DeinitNetworking(); + //Aurora::IO::Net::DeinitNetworking(); Aurora::Processes::Deinit(); Aurora::Exit::DeinitExit(); } diff --git a/Source/IO/Net/BaseChannel.cpp b/Source/IO/Net/BaseChannel.cpp deleted file mode 100644 index 4cffbbf8..00000000 --- a/Source/IO/Net/BaseChannel.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseChannel.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "BaseChannel.hpp" - -namespace Aurora::IO::Net -{ - bool BaseChannel::GetRemoteEndpoint(ConnectionEndpoint &out) - { - return {}; - } - - bool BaseChannel::ReadAsync(const Memory::MemoryViewStreamWrite &memory, bool all) - { - return {}; - } - - bool BaseChannel::PeekAsync(const Memory::MemoryViewStreamWrite &memory) - { - return {}; - } - - bool BaseChannel::SeekAsync(int signedDistanceFromCur) - { - return {}; - } - - bool BaseChannel::ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all) - { - return {}; - } - - bool BaseChannel::WriteAsync(const Memory::MemoryViewStreamRead &memory) - { - return {}; - } - - bool BaseChannel::WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr &input) - { - return {}; - } - - bool BaseChannel::WriteSync(const Memory::MemoryViewStreamRead &memory) - { - return {}; - } - - AuUInt BaseChannel::GetInternalInputRingBuffer() - { - return {}; - } - - bool BaseChannel::SetInternalInputRingBuffer(AuUInt bytes) - { - return {}; - } - - void BaseChannel::SetRecvLength(AuUInt32 length) - { - } - - AuUInt32 BaseChannel::GetRecvLength() - { - return {}; - } - - void BaseChannel::BufferInputStreamAdhoc(bool value) - { - } - - void BaseChannel::ConfigureHasDataCallback(bool enabled) - { - } - - void BaseChannel::ReconfigureStreams(const StreamConfig &config) - { - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseChannel.hpp b/Source/IO/Net/BaseChannel.hpp deleted file mode 100644 index 873cf213..00000000 --- a/Source/IO/Net/BaseChannel.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseChannel.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#include "PlatformChannel.hpp" - -namespace Aurora::IO::Net -{ - struct BaseSocket; - - struct BaseChannel : public ISocketChannel - { - BaseChannel(BaseSocket *base) : base_(base), platform_(base) - {} - - bool GetRemoteEndpoint(ConnectionEndpoint &out); - - bool ReadAsync(const Memory::MemoryViewStreamWrite &memory, bool all) override; - bool PeekAsync(const Memory::MemoryViewStreamWrite &memory) override; - bool SeekAsync(int signedDistanceFromCur) override; - bool ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all) override; - bool WriteAsync(const Memory::MemoryViewStreamRead &memory) override; - bool WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr &input) override; - bool WriteSync(const Memory::MemoryViewStreamRead &memory) override; - - AuUInt GetInternalInputRingBuffer() override; - bool SetInternalInputRingBuffer(AuUInt bytes) override; - - void SetRecvLength(AuUInt32 length) override; - AuUInt32 GetRecvLength() override; - - void BufferInputStreamAdhoc(bool value) override; - - void ConfigureHasDataCallback(bool enabled) override; - - void ReconfigureStreams(const StreamConfig &config) override; - - private: - PlatformChannel platform_; - BaseSocket *base_; - }; - -#define IMPLEMENT_PLATFORM_PROXY(access) \ - \ - bool ReadAsync(const Memory::MemoryViewStreamWrite &memory, bool all) override \ - { \ - return access ReadAsync(memory, all); \ - } \ - \ - bool PeekAsync(const Memory::MemoryViewStreamWrite &memory) override \ - { \ - return access PeekAsync(memory); \ - } \ - \ - bool SeekAsync(int signedDistanceFromCur) override \ - { \ - return access SeekAsync(signedDistanceFromCur); \ - } \ - \ - bool ReadSync(const Memory::MemoryViewStreamWrite &memory, bool all) override \ - { \ - return access ReadSync(memory, all); \ - } \ - \ - bool WriteAsync(const Memory::MemoryViewStreamRead &memory) override \ - { \ - return access WriteAsync(memory); \ - } \ - \ - bool WriteAsync(const Memory::MemoryViewStreamRead &memory, AuUInt fence, const AuSPtr &input) override \ - { \ - return access WriteAsync(memory, fence, input); \ - } \ - \ - bool WriteSync(const Memory::MemoryViewStreamRead &memory) override \ - { \ - return access WriteAsync(memory); \ - } \ - \ - AuUInt GetInternalInputRingBuffer() override \ - { \ - return access GetInternalInputRingBuffer(); \ - } \ - \ - bool SetInternalInputRingBuffer(AuUInt bytes) override \ - { \ - return access SetInternalInputRingBuffer(bytes); \ - } \ - \ - void SetRecvLength(AuUInt32 length) override \ - { \ - access SetRecvLength(length); \ - } \ - \ - AuUInt32 GetRecvLength() override \ - { \ - return access GetRecvLength(); \ - } \ - \ - void BufferInputStreamAdhoc(bool value) override \ - { \ - access BufferInputStreamAdhoc(value); \ - } \ - \ - void ConfigureHasDataCallback(bool enabled) override \ - { \ - access ConfigureHasDataCallback(enabled); \ - } \ - \ - void ReconfigureStreams(const StreamConfig &config) override \ - { \ - access ReconfigureStreams(config); \ - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseLocalClient.cpp b/Source/IO/Net/BaseLocalClient.cpp deleted file mode 100644 index 2c9cbcbe..00000000 --- a/Source/IO/Net/BaseLocalClient.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseLocalClient.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "BaseSocket.hpp" -#include "BaseLocalClient.hpp" - -namespace Aurora::IO::Net -{ - bool BaseLocalClient::Connect() - { - return {}; - } - - void BaseLocalClient::ConnectAsync() - { - - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseLocalClient.hpp b/Source/IO/Net/BaseLocalClient.hpp deleted file mode 100644 index 40958e4a..00000000 --- a/Source/IO/Net/BaseLocalClient.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseLocalClient.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#include "BaseSocket.hpp" - -namespace Aurora::IO::Net -{ - struct BaseLocalClient : ILocalClientSocket - { - bool Connect() override; - void ConnectAsync() override; - - IMPLEMENT_PLATFORM_PROXY(osSocket_.) - IMPLEMENT_IBASICSOCKETTHREADED(osSocket_.) - - private: - BaseSocket osSocket_; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/BaseNetworkInterface.cpp b/Source/IO/Net/BaseNetworkInterface.cpp deleted file mode 100644 index d2245ae3..00000000 --- a/Source/IO/Net/BaseNetworkInterface.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseNetworkInterface.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "BaseNetworkInterface.hpp" - -namespace Aurora::IO::Net -{ - AuList BaseNetworkInterface::ResolveSocketSync(const SocketHostName &hostname, AuUInt16 port) - { - return {}; - } - - AuList BaseNetworkInterface::ResolveServiceSync(const ServiceEndpoint &service) - { - return {}; - } - - bool BaseNetworkInterface::SendDatagramAsync(const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) - { - return {}; - } - - bool BaseNetworkInterface::SendDatagramAsync(const AuSPtr &datagramServer, const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) - { - return {}; - } - - AuSPtr BaseNetworkInterface::GetSocketFactory() - { - return {}; - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseNetworkInterface.hpp b/Source/IO/Net/BaseNetworkInterface.hpp deleted file mode 100644 index 9cec6027..00000000 --- a/Source/IO/Net/BaseNetworkInterface.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseNetworkInterface.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct BaseNetworkInterface : INetworkInterface - { - AuList ResolveSocketSync(const SocketHostName &hostname, AuUInt16 port) override; - AuList ResolveServiceSync(const ServiceEndpoint &service) override; - - bool SendDatagramAsync(const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) override; - bool SendDatagramAsync(const AuSPtr &datagramServer, const ConnectionEndpoint &endpoint, const Memory::MemoryViewRead &memory) override; - - AuSPtr GetSocketFactory() override; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/BaseServer.cpp b/Source/IO/Net/BaseServer.cpp deleted file mode 100644 index e1299356..00000000 --- a/Source/IO/Net/BaseServer.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseServer.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "BaseSocket.hpp" -#include "BaseServer.hpp" - -namespace Aurora::IO::Net -{ - BaseServer::BaseServer(BaseSocket &&socket) : osSocket_(socket) - {} - - BaseServer::~BaseServer() - {} - - bool BaseServer::GetLocalEndpoint(ConnectionEndpoint &out) - { - return {}; - } - - void BaseServer::GetClients(AuList> &clients) - { - - } - - bool BaseServer::Listen() - { - return {}; - } - - void BaseServer::ReconfigureDefaultStream(const StreamConfig &config) - { - - } - - BaseSocket &BaseServer::ToPlatformSocket() - { - return this->osSocket_; - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseServer.hpp b/Source/IO/Net/BaseServer.hpp deleted file mode 100644 index 4f4a0f95..00000000 --- a/Source/IO/Net/BaseServer.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseServer.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ -#define IMPLEMENT_BASE_SERVER_PROXY(access) \ - Error_t GetLastError() override \ - { \ - return access GetLastError(); \ - } \ - \ - void Shutdown() override \ - { \ - return access Shutdown(); \ - } \ - \ - AuSPtr SetContext(const AuSPtr &newContext) \ - { \ - return access SetContext(newContext); \ - } \ - \ - AuSPtr GetContext() override \ - { \ - return access GetContext(); \ - } \ - \ - SocketStat GetStats() override \ - { \ - return access GetStats(); \ - } \ - \ - EUnderlyingModel GetThreadModel() override \ - { \ - return access GetThreadModel(); \ - } - - struct BaseServer : public IServer - { - BaseServer(BaseSocket &&socket); - ~BaseServer(); - - bool GetLocalEndpoint(ConnectionEndpoint &out) override; - void GetClients(AuList> &clients) override; - bool Listen() override; - void ReconfigureDefaultStream(const StreamConfig &config) override; - - BaseSocket &ToPlatformSocket(); - - IMPLEMENT_BASE_SERVER_PROXY(osSocket_.); - - private: - BaseSocket osSocket_; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/BaseSocket.cpp b/Source/IO/Net/BaseSocket.cpp deleted file mode 100644 index 041a71a0..00000000 --- a/Source/IO/Net/BaseSocket.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseSocket.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "BaseSocket.hpp" - -namespace Aurora::IO::Net -{ - PlatformSocket_t &BaseSocket::ToPlatformSocket() - { - return this->osSocket_; - } - - BaseChannel &BaseSocket::ToChannel() - { - return this->channel_; - } - - bool BaseSocket::PumpRead() - { - return {}; - } - - bool BaseSocket::PumpWrite() - { - return {}; - } - - bool BaseSocket::Pump() - { - return {}; - } - - void BaseSocket::Run(int idx, AuUInt32 timeout) - { - - } -} \ No newline at end of file diff --git a/Source/IO/Net/BaseSocket.hpp b/Source/IO/Net/BaseSocket.hpp deleted file mode 100644 index 9ff0eaee..00000000 --- a/Source/IO/Net/BaseSocket.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: BaseSocket.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#include "BaseChannel.hpp" - -#include "PlatformSocket.hpp" - -namespace Aurora::IO::Net -{ -#define IMPLEMENT_IBASICSOCKET(access) \ - bool GetLocalEndpoint(ConnectionEndpoint &out) override \ - { \ - return access GetLocalEndpoint(out); \ - } \ - \ - bool IsActive() override \ - { \ - return access IsActive(); \ - } \ - Error_t GetLastError() override \ - { \ - return access GetLastError(); \ - } \ - void Shutdown() override \ - { \ - access Shutdown(); \ - } \ - AuSPtr SetContext(const AuSPtr &newContext) override \ - { \ - return access SetContext(newContext); \ - } \ - AuSPtr GetContext() override \ - { \ - return access GetContext(); \ - } \ - SocketStat GetStats() override \ - { \ - return access GetStats(); \ - } \ - EUnderlyingModel GetThreadModel() override \ - { \ - return access GetThreadModel(); \ - } - -#define IMPLEMENT_IBASICSOCKETTHREADED(access) \ - bool PumpRead() override \ - { \ - return access PumpRead(); \ - } \ - bool PumpWrite() override \ - { \ - return access PumpWrite(); \ - } \ - bool Pump() override \ - { \ - return access Pump(); \ - } \ - void Run(int idx, AuUInt32 timeout) override \ - { \ - access Run(idx, timeout); \ - } - - struct BaseSocket : public ISocket - { - BaseSocket() : channel_(this) - {} - - PlatformSocket_t &ToPlatformSocket(); - BaseChannel &ToChannel(); - - bool PumpRead() override; - bool PumpWrite() override; - bool Pump() override; - - void Run(int idx, AuUInt32 timeout) override; - - bool GetRemoteEndpoint(ConnectionEndpoint &out) override - { - return channel_.GetRemoteEndpoint(out); - } - - IMPLEMENT_IBASICSOCKET(osSocket_.) - IMPLEMENT_PLATFORM_PROXY(channel_.) - private: - - PlatformSocket_t osSocket_; - BaseChannel channel_; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/HelloNet.Win32.cpp b/Source/IO/Net/HelloNet.Win32.cpp deleted file mode 100644 index de7720d9..00000000 --- a/Source/IO/Net/HelloNet.Win32.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: HelloNet.Win32.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "HelloNet.Win32.hpp" - -namespace Aurora::IO::Net -{ - void InitNetworking() - { - - } - - void DeinitNetworking() - { - - } -} diff --git a/Source/IO/Net/HelloNet.Win32.hpp b/Source/IO/Net/HelloNet.Win32.hpp deleted file mode 100644 index ad29c667..00000000 --- a/Source/IO/Net/HelloNet.Win32.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: HelloNet.Win32.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - void InitNetworking(); - void DeinitNetworking(); -} diff --git a/Source/IO/Net/IPAddress.cpp b/Source/IO/Net/IPAddress.cpp deleted file mode 100644 index d36f21aa..00000000 --- a/Source/IO/Net/IPAddress.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: IPAddress.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "IPAddress.hpp" - -namespace Aurora::IO::Net -{ - IPAddress::IPAddress() - { - this->ip = EIPProtocol::eEnumInvalid; - } - - IPAddress::IPAddress(const AuString &parse) - { - unsigned char buf[64]; - static_assert(AuArraySize(buf) >= sizeof(struct in6_addr)); - static_assert(AuArraySize(buf) >= sizeof(struct in_addr)); - - this->ip = EIPProtocol::eEnumInvalid; - - bool isIPV4 {}; - if (parse.size() > 4) - { - isIPV4 = parse[1] == '.' || parse[2] == '.'; - } - - if (inet_pton(isIPV4 ? AF_INET : AF_INET6, parse.c_str(), buf) != 1) - { - return; - } - - if (isIPV4) - { - AuWriteU32BE(this->v4, 0, AuReadU32LE(buf, 0)); - } - else - { - auto ipv6 = reinterpret_cast(buf); - AuWriteU16BE(&this->v6[0], 0, ipv6[0]); - AuWriteU16BE(&this->v6[1], 0, ipv6[1]); - AuWriteU16BE(&this->v6[2], 0, ipv6[2]); - AuWriteU16BE(&this->v6[3], 0, ipv6[3]); - AuWriteU16BE(&this->v6[4], 0, ipv6[4]); - AuWriteU16BE(&this->v6[5], 0, ipv6[5]); - AuWriteU16BE(&this->v6[6], 0, ipv6[6]); - } - } - - AuString IPAddress::ToString() const - { - return {}; - } - - bool IPAddress::IsValid() const - { - return EIPProtocolIsValid(this->ip); - } -} \ No newline at end of file diff --git a/Source/IO/Net/IPAddress.hpp b/Source/IO/Net/IPAddress.hpp deleted file mode 100644 index 65c369d2..00000000 --- a/Source/IO/Net/IPAddress.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: IPAddress.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/Net.cpp b/Source/IO/Net/Net.cpp deleted file mode 100644 index be4452d9..00000000 --- a/Source/IO/Net/Net.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: Net.cpp - Date: 2021-7-2 - Author: Reece -***/ -#include -#include "Net.hpp" - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/Net.hpp b/Source/IO/Net/Net.hpp deleted file mode 100644 index eee53ed8..00000000 --- a/Source/IO/Net/Net.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: Net.hpp - Date: 2021-7-2 - Author: Reece -***/ -#pragma once - -#include "SocketStatChannel.hpp" - -#if defined(AURORA_IS_POSIX_DERIVED) - #include -#elif defined(AURORA_IS_MODERNNT_DERIVED) - #include -#endif - - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/NetworkingPool.cpp b/Source/IO/Net/NetworkingPool.cpp deleted file mode 100644 index b386740c..00000000 --- a/Source/IO/Net/NetworkingPool.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: NetworkingPool.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "NetworkingPool.hpp" - -namespace Aurora::IO::Net -{ - AuUInt32 NetworkingPool::Pump(AuUInt8 workerId) - { - return {}; - } - - AuUInt32 NetworkingPool::PumpRead(AuUInt8 workerId) - { - return {}; - } - - AuUInt32 NetworkingPool::PumpWrite(AuUInt8 workerId) - { - return {}; - } - - AuUInt32 NetworkingPool::PollWorker(AuUInt8 workerId) - { - return {}; - } - - AuUInt32 NetworkingPool::RunWorker(AuUInt8 workerId, AuUInt32 timeout) - { - return {}; - } - - bool NetworkingPool::BeginReadPollingOnWorkQueues(const WorkPoolGroup &workGroup) - { - return {}; - } - - bool NetworkingPool::BeginSubmissionsOnOnWorkQueues(const WorkPoolGroup &workGroup) - { - return {}; - } - - void NetworkingPool::StopPollingOnWorkQueues() - { - - } - - AuUInt8 NetworkingPool::GetWorkers() - { - return {}; - } - - AuSPtr NetworkingPool::GetNetworkInterface() - { - return {}; - } - - void NetworkingPool::Shutdown() - { - - } -} \ No newline at end of file diff --git a/Source/IO/Net/NetworkingPool.hpp b/Source/IO/Net/NetworkingPool.hpp deleted file mode 100644 index b1041ab7..00000000 --- a/Source/IO/Net/NetworkingPool.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: NetworkingPool.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct NetworkingPool : INetworkingPool - { - // A: - AuUInt32 Pump(AuUInt8 workerId) override; - - // B: - AuUInt32 PumpRead(AuUInt8 workerId) override; - AuUInt32 PumpWrite(AuUInt8 workerId) override; - - // C: - AuUInt32 PollWorker(AuUInt8 workerId) override; - AuUInt32 RunWorker(AuUInt8 workerId, AuUInt32 timeout) override; - - // D: - bool BeginReadPollingOnWorkQueues(const WorkPoolGroup &workGroup) override; - bool BeginSubmissionsOnOnWorkQueues(const WorkPoolGroup &workGroup) override; - void StopPollingOnWorkQueues() override; - - // E: - - - AuUInt8 GetWorkers() override; - - AuSPtr GetNetworkInterface() override; - - void Shutdown() override; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/PlatformChannel.Win32.cpp b/Source/IO/Net/PlatformChannel.Win32.cpp deleted file mode 100644 index e3a05fcc..00000000 --- a/Source/IO/Net/PlatformChannel.Win32.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: PlatformChannel.Win32.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "PlatformChannel.hpp" -#include "PlatformChannel.Win32.hpp" - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/PlatformChannel.hpp b/Source/IO/Net/PlatformChannel.hpp deleted file mode 100644 index 66b276c1..00000000 --- a/Source/IO/Net/PlatformChannel.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: PlatformChannel.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct BaseSocket; - struct PlatformChannel - { - PlatformChannel(BaseSocket *base) : base_(base) - {} - - EUnderlyingModel SocketThreadModel(); - void WritePerModel(const void *pIn, AuUInt length); - void ReadPerModel(const void *pIn, AuUInt length); - - bool GetLocalEndpoint(ConnectionEndpoint &out); - bool GetRemoteEndpoint(ConnectionEndpoint &out); - - private: - BaseSocket *base_; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/PlatformSocket.Win32.cpp b/Source/IO/Net/PlatformSocket.Win32.cpp deleted file mode 100644 index d20fabeb..00000000 --- a/Source/IO/Net/PlatformSocket.Win32.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: PlatformSocket.Win32.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "PlatformSocket.Win32.hpp" - -namespace Aurora::IO::Net -{ - bool Win32Socket::IsActive() - { - return {}; - } - - Error_t Win32Socket::GetLastError() - { - return {}; - } - - void Win32Socket::Shutdown() - { - - } - - AuSPtr Win32Socket::SetContext(const AuSPtr &newContext) - { - return {}; - } - - AuSPtr Win32Socket::GetContext() - { - return {}; - } - - bool Win32Socket::GetLocalEndpoint(ConnectionEndpoint &out) - { - return {}; - } - - SocketStat Win32Socket::GetStats() - { - return {}; - } - - EUnderlyingModel Win32Socket::GetThreadModel() - { - return EUnderlyingModel::eAsync; - } -} diff --git a/Source/IO/Net/PlatformSocket.Win32.hpp b/Source/IO/Net/PlatformSocket.Win32.hpp deleted file mode 100644 index 6d80357c..00000000 --- a/Source/IO/Net/PlatformSocket.Win32.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: PlatformSocket.Win32.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct Win32Socket : IBasicSocket - { - virtual bool IsActive() override; - virtual Error_t GetLastError() override; - virtual void Shutdown() override; - virtual AuSPtr SetContext(const AuSPtr &newContext) override; - virtual AuSPtr GetContext() override; - virtual bool GetLocalEndpoint(ConnectionEndpoint &out) override; - virtual SocketStat GetStats() override; - virtual EUnderlyingModel GetThreadModel() override; - }; - - using PlatformSocket_t = Win32Socket; -} \ No newline at end of file diff --git a/Source/IO/Net/PlatformSocket.hpp b/Source/IO/Net/PlatformSocket.hpp deleted file mode 100644 index 255d629b..00000000 --- a/Source/IO/Net/PlatformSocket.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: PlatformSocket.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -#if defined(AURORA_PLATFORM_WIN32) - #include "PlatformSocket.Win32.hpp" -#endif - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/SocketFactory.cpp b/Source/IO/Net/SocketFactory.cpp deleted file mode 100644 index 39f8160a..00000000 --- a/Source/IO/Net/SocketFactory.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: SocketFactory.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "SocketFactory.hpp" - -namespace Aurora::IO::Net -{ - bool BasePlatformSocketFactory::NewServer(const ServerInfo &listen, AuSPtr &out) - { - return {}; - } - - bool BasePlatformSocketFactory::NewTlsServer(const TLSServerInfo &keys, AuSPtr &out) - { - return {}; - } - - bool BasePlatformSocketFactory::NewClient(const ClientConfig &info, AuSPtr &out) - { - return {}; - } - - bool BasePlatformSocketFactory::NewTlsClient(const TLSClientConfig &info, AuSPtr &out) - { - return {}; - } -} \ No newline at end of file diff --git a/Source/IO/Net/SocketFactory.hpp b/Source/IO/Net/SocketFactory.hpp deleted file mode 100644 index d1227cdb..00000000 --- a/Source/IO/Net/SocketFactory.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: SocketFactory.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct BasePlatformSocketFactory : public ISocketFactory - { - bool NewServer(const ServerInfo &listen, AuSPtr &out) override; - bool NewTlsServer(const TLSServerInfo &keys, AuSPtr &out) override; - - bool NewClient(const ClientConfig &info, AuSPtr &out) override; - bool NewTlsClient(const TLSClientConfig &info, AuSPtr &out) override; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/SocketStatAverageBps.hpp b/Source/IO/Net/SocketStatAverageBps.hpp deleted file mode 100644 index 5e550365..00000000 --- a/Source/IO/Net/SocketStatAverageBps.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: SocketStatAverageBps.hpp - Date: 2021-10-31 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - struct SocketStatAverageBps - { - inline AuUInt32 GetBytesPerMS(AuUInt32 timeNow) - { - if (!frameLastEnd) return bytesTransferred; - return (double(bytesTransferred) / (double(timeNow - frameLastEnd) + AuNumericLimits::epsilon())); - } - - inline AuUInt32 GetBytesPerSecondNormalized(AuUInt32 timeNow) - { - AU_LOCK_GUARD(lock); - - // If timeNow isn't at least that of one socket frame, then we just have to return some old data - if (frameZero) return GetLastBytesPerSecond(); - - // Cool we can extrapolate usage using a time weight at least that of one server frame - - // Some useful variables... - auto frameAtPoint = GetBytesPerMS(timeNow); - auto timeElapsed = timeNow - frameLastEnd; // time elapsed since last packet dispatch finish. makes sense to use this is the packet delta of a high bandwidth stream - - // Edge case: we aren't receiving much data. if we have more than 1 second of data, we should use the stream average - if (timeElapsed > 1000) return frameAtPoint / 1000; // from ms - // else assume constant usage will continue to trend for at least another second - // the actual extrapolation - auto weight = double(1000) / double(timeElapsed); - return double(frameAtPoint) * weight; - } - - inline AuUInt32 GetLastBytesPerSecond() - { - AU_LOCK_GUARD(lock); - return double(lastBytesTransferred) / (double(frameLastEnd - frameLastStart) + AuNumericLimits::epsilon()) * 1000.f; - } - - inline void Reset() - { - bytesTransferred = 0; - frameStart = 0; - frameLastEnd = 0; - frameLastStart = 0; - frameZero = true; - lastBytesTransferred = 0; - } - - inline void Add(AuUInt32 timeNow, AuUInt32 bytes) - { - AU_LOCK_GUARD(lock); - auto nextTick = frameLastEnd + 1000; - - if (nextTick < timeNow) - { - frameLastEnd = timeNow; - frameLastStart = AuExchange(frameStart, timeNow); - lastBytesTransferred = AuExchange(bytesTransferred, bytes); - frameZero = true; - } - else - { - frameZero = false; - bytesTransferred += bytes; - } - } - - - AuThreadPrimitives::SpinLock lock; - - AuUInt32 frameStart {}; - AuUInt32 bytesTransferred {}; - - AuUInt32 frameLastStart {}; - AuUInt32 frameLastEnd {}; - AuUInt32 lastBytesTransferred {}; - - bool frameZero {true}; - }; -} \ No newline at end of file diff --git a/Source/IO/Net/SocketStatChannel.hpp b/Source/IO/Net/SocketStatChannel.hpp deleted file mode 100644 index bc6d5a9f..00000000 --- a/Source/IO/Net/SocketStatChannel.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/*** - Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: SocketStatChannel.hpp - Date: 2021-10-31 - Author: Reece -***/ -#pragma once - -#include "SocketStatAverageBps.hpp" - -namespace Aurora::IO::Net -{ - struct SocketStatChannel - { - SocketStatAverageBps bandwidth; - AuUInt64 total; - - // Interpolated bytes per second, may be less than expected (returning frame -1) - inline AuUInt32 GetAverageBytesPerSecond() - { - return bandwidth.GetLastBytesPerSecond(); - } - - inline AuUInt32 GetBytesPerSecond() - { - return bandwidth.GetBytesPerSecondNormalized(Time::CurrentClockMS()); - } - - inline void Add(AuUInt32 bytes) - { - total += bytes; - bandwidth.Add(Time::CurrentClockMS(), bytes); - } - }; -} \ No newline at end of file diff --git a/Source/IO/Net/WorkPoolGroup.cpp b/Source/IO/Net/WorkPoolGroup.cpp deleted file mode 100644 index 4750828b..00000000 --- a/Source/IO/Net/WorkPoolGroup.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: WorkPoolGroup.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "WorkPoolGroup.hpp" - -namespace Aurora::IO::Net -{ - WorkPoolGroup::WorkPoolGroup() - { - asyncWorkGroup = AuAsync::kThreadIdAny; - asyncWorkPoolOffsetOrAny = AuAsync::kThreadIdAny; - } -} \ No newline at end of file diff --git a/Source/IO/Net/WorkPoolGroup.hpp b/Source/IO/Net/WorkPoolGroup.hpp deleted file mode 100644 index 9d9747c6..00000000 --- a/Source/IO/Net/WorkPoolGroup.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: WorkPoolGroup.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file diff --git a/Source/IO/Net/WorkRange.cpp b/Source/IO/Net/WorkRange.cpp deleted file mode 100644 index d3c6ef6f..00000000 --- a/Source/IO/Net/WorkRange.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: WorkRange.cpp - Date: 2022-2-1 - Author: Reece -***/ -#include -#include "Net.hpp" -#include "WorkRange.hpp" - -namespace Aurora::IO::Net -{ - WorkRange::WorkRange() - { - workerOffsetOrAny = AuAsync::kThreadIdAny; - workerCountOrAny = AuAsync::kThreadIdAny; - } -} \ No newline at end of file diff --git a/Source/IO/Net/WorkRange.hpp b/Source/IO/Net/WorkRange.hpp deleted file mode 100644 index ffb5693a..00000000 --- a/Source/IO/Net/WorkRange.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/*** - Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. - - File: WorkRange.hpp - Date: 2022-2-1 - Author: Reece -***/ -#pragma once - -namespace Aurora::IO::Net -{ - -} \ No newline at end of file