AuroraRuntime/Source/IO/Net/AuNetSocket.hpp
Reece Wilson f43251c8fc [+] AuNet::ISocketChannelEventListener
[+] AuFS::UpdateTimes
[+] AuFS::UpdateFileTimes
[+] AuFS::CompressEx
[*] AuFS::Compress now rejects files that look to be already compressed
[+] AuFS::DecompressEx
[+] AuFS::Create
[+] AuFS::WriteNewFile
[+] AuFS::WriteNewString
[+] AuFs::FileAttrsList
[+] AuFs::FileAttrsGet
[+] AuFs::FileAttrsSet
[+] DirectoryLogger::uMaxLogsOrZeroBeforeCompress
[+] ISocketChannel.AddEventListener
[+] ISocketChannel.AddEventListener
[+] DirectoryLogger.uMaxLogsOrZeroBeforeCompress
[*] Fix UNIX regression
[*] Fix up stream socket channel realloc IPC
[*] Fix shutdown regression in pretty much everything thanks to 8ff81df1's dumbass fix
    (fixes fence regression on shutdown)
[*] Fix DirDeleterEx formatting of reported failed paths
[*] Fix up file not truncated if already exists bugs. Extended and alternative apis added.
[*] Fix ICompressionStream::ReadEx returning the wrong read value
[+] Legacy compression API can now self-correct once newer stream processor objects are added
2023-02-04 19:43:01 +00:00

155 lines
4.1 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuNetSocket.hpp
Date: 2022-8-16
Author: Reece
***/
#pragma once
#include "AuNetSocketChannel.hpp"
#include "AuNetSocketConnectOperation.hpp"
namespace Aurora::IO::FS
{
struct FileHandle;
}
namespace Aurora::IO::Net
{
struct NetInterface;
struct NetWorker;
struct SocketBase;
struct SocketConnectOperation;
struct SocketServerAcceptReadOperation;
struct SocketBase : virtual ISocket, AuEnableSharedFromThis<SocketBase>
{
friend struct SocketServerAcceptReadOperation;
SocketBase(struct NetInterface *pInterface,
struct NetWorker *pWorker,
const AuSPtr<ISocketDriver> &pSocketDriver,
AuUInt osHandle);
SocketBase(struct NetInterface *pInterface,
struct NetWorker *pWorker,
const AuSPtr<ISocketDriver> &pSocketDriver,
const NetEndpoint &endpoint);
SocketBase(struct NetInterface *pInterface,
struct NetWorker *pWorker,
const AuSPtr<ISocketDriver> &pSocketDriver,
const AuPair<NetHostname, AuUInt16> &endpoint,
AuNet::ETransportProtocol eProtocol);
SocketBase(struct NetInterface *pInterface,
struct NetWorker *pWorker,
const AuSPtr<ISocketDriver> &pSocketDriver,
const NetSocketConnectMany &connectMany);
virtual ~SocketBase();
bool TryStartResolve();
bool ConnectNext();
bool Connect(const NetEndpoint &endpoint);
AuUInt ToPlatformHandle() override;
AuSPtr<ISocketDriver> GetUserDriver() override;
const NetEndpoint &GetRemoteEndpoint() override;
const NetEndpoint &GetLocalEndpoint() override;
const NetError &GetError() override;
void ConnectFinished();
void ConnectFailed(const NetError &error);
void DoMain();
void SendErrorNoStream(const NetError &error);
void SendErrorBeginShutdown(const NetError &error);
void SendOnData();
void RejectAllListeners();
void CompleteAllListeners();
virtual AuSPtr<ISocketChannel> ToChannel() override;
virtual void Destroy() override;
void ShutdownLite();
INetWorker *ToWorker();
NetWorker *ToWorkerEx();
bool SendPreestablish(struct SocketServer *pServer = nullptr);
void SendEnd();
void SendFinalize();
bool IsValid();
SocketConnectOperation connectOperation;
virtual void UpdateNagleAnyThread(bool bDisableNagle) = 0;
virtual void FinishConstructAsync() = 0;
virtual bool PrepareConnectOperations() = 0;
virtual bool MakeNonblocking() = 0;
virtual bool UpdateLocalEndpoint() = 0;
virtual bool UpdateRemoteEndpoint() = 0;
virtual bool TryBindAnyLocal() = 0;
virtual bool ConnectOverlapped() = 0;
virtual bool ConnectNonblocking() = 0;
virtual bool ConnectBlocking() = 0;
virtual void CloseSocket() = 0;
virtual void RenewSocket() = 0;
AuUInt endpointSize_ {};
bool bHasFinalized_ {};
bool bHasEnded {};
bool bResolving_ {};
protected:
AuUInt osHandle_ {};
friend struct NetWriteQueue;
friend struct SocketChannelOutput;
NetEndpoint remoteEndpoint_;
NetEndpoint localEndpoint_;
bool bForceFailConstruct_ {};
bool bHasRemoteMany_ {};
NetSocketConnectMany connectMany_;
NetWorker *pWorker_;
NetInterface *pInterface_;
SocketChannel socketChannel_;
AuSPtr<ISocketDriver> pSocketDriver_;
AuSPtr<FS::FileHandle> osHandleOwner_;
NetError error_;
bool bHasErrored_ {};
bool bHasConnected_ {};
bool bHasPreestablished_ {};
AuString resolveLater {};
};
}
#if defined(AURORA_IS_MODERNNT_DERIVED)
#include "AuNetSocket.NT.hpp"
#else
#include "AuNetSocket.Unix.hpp"
#endif