mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-21 19:15:46 +00:00
sockets: Make fd member variable protected
Other things shouldn't be able to directly mess around with the descriptor
This commit is contained in:
parent
8d4458ef24
commit
c8da75b7ed
2 changed files with 17 additions and 6 deletions
|
@ -32,6 +32,10 @@ public:
|
|||
std::unique_ptr<SocketBase> socket;
|
||||
SockAddrIn sockaddr_in;
|
||||
};
|
||||
|
||||
SocketBase() = default;
|
||||
explicit SocketBase(SOCKET fd_) : fd{fd_} {}
|
||||
|
||||
virtual ~SocketBase() = default;
|
||||
|
||||
virtual SocketBase& operator=(const SocketBase&) = delete;
|
||||
|
@ -89,12 +93,19 @@ public:
|
|||
|
||||
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
|
||||
|
||||
[[nodiscard]] SOCKET GetFD() const {
|
||||
return fd;
|
||||
}
|
||||
|
||||
protected:
|
||||
SOCKET fd = INVALID_SOCKET;
|
||||
};
|
||||
|
||||
class Socket : public SocketBase {
|
||||
public:
|
||||
Socket() = default;
|
||||
explicit Socket(SOCKET fd_) : SocketBase{fd_} {}
|
||||
|
||||
~Socket() override;
|
||||
|
||||
Socket(const Socket&) = delete;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue