J Reece Wilson
1e4082c02f
[+] NetSocketBind::uDefaultInputStreamSize [+] NetDatagramBind::uDefaultInputStreamSize
94 lines
2.7 KiB
C++
94 lines
2.7 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: AuNetSocketServer.hpp
|
|
Date: 2022-8-22
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
#include "AuNetSocket.hpp"
|
|
|
|
#if defined(AURORA_COMPILER_MSVC)
|
|
#pragma warning(disable: 4250)
|
|
#endif
|
|
|
|
namespace Aurora::IO::Net
|
|
{
|
|
struct SocketServer;
|
|
|
|
struct SocketServer : virtual Socket, virtual ISocketDriver, virtual ISocketServer
|
|
{
|
|
SocketServer(struct NetInterface *pInterface,
|
|
struct NetWorker *pWorker,
|
|
const AuSPtr<ISocketServerDriver> &pDriver,
|
|
const AuSPtr<ISocketDriverFactory> &pFactory,
|
|
AuUInt32 uMaxConnections,
|
|
AuUInt32 uDefaultInputStreamSize,
|
|
bool bMultiThreaded);
|
|
|
|
void Init(const NetEndpoint &localAddress);
|
|
void Listen(const NetEndpoint &localAddress, bool bBind = true, bool bListen = true);
|
|
void Accept();
|
|
|
|
AuSPtr<ISocketServerDriver> GetServerDriver() override;
|
|
AuSPtr<ISocketDriverFactory> GetFactory();
|
|
|
|
virtual void FinishConstructAsync() override;
|
|
|
|
virtual void Shutdown(bool bNow) override;
|
|
virtual void Destroy() override;
|
|
|
|
void ScheduleAcceptTick();
|
|
|
|
virtual void DoNonblockingReadTick() = 0;
|
|
virtual bool InitSocket(const NetEndpoint &localAddress) = 0;
|
|
virtual bool ImplBind() = 0;
|
|
virtual bool ImplListen() = 0;
|
|
virtual bool BeginAcceptLoop() = 0;
|
|
|
|
virtual void DetroyServer() = 0;
|
|
|
|
const bool bMultiThreaded;
|
|
const AuUInt32 uDefaultInputStreamSize;
|
|
protected:
|
|
|
|
// INTERFACE: base os socket
|
|
|
|
virtual bool PrepareConnectOperations() override;
|
|
|
|
virtual bool UpdateLocalEndpoint() override;
|
|
virtual bool UpdateRemoteEndpoint() override;
|
|
|
|
virtual bool TryBindAnyLocal() override;
|
|
|
|
virtual bool ConnectOverlapped() override;
|
|
virtual bool ConnectNonblocking() override;
|
|
virtual bool ConnectBlocking() override;
|
|
|
|
// INTERFACE: SOCKET DRIVER (for redirecting callbacks)
|
|
bool OnPreestablish(const AuSPtr<ISocket> &pInforming) override;
|
|
|
|
void OnEstablish() override;
|
|
|
|
virtual void OnStreamUpdated() override;
|
|
|
|
virtual void OnFatalErrorReported(const NetError &error) override;
|
|
|
|
virtual void OnEnd() override;
|
|
|
|
virtual void OnFinalize() override;
|
|
|
|
private:
|
|
AuSPtr<ISocketServerDriver> pDriver_;
|
|
AuUInt32 uMaxConnections_;
|
|
AuSPtr<ISocketDriverFactory> pFactory_;
|
|
|
|
};
|
|
}
|
|
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
#include "AuNetSocketServer.NT.hpp"
|
|
#else
|
|
#include "AuNetSocketServer.Unix.hpp"
|
|
#endif |