From 00bc7e6b380f432e4a7d957a2b2d460a715176f5 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 4 Mar 2021 13:43:35 -0600 Subject: Common: Add RAII object that initializes and cleans up winsock --- Source/Core/Common/SocketContext.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Source/Core/Common/SocketContext.cpp (limited to 'Source/Core/Common/SocketContext.cpp') diff --git a/Source/Core/Common/SocketContext.cpp b/Source/Core/Common/SocketContext.cpp new file mode 100644 index 0000000000..e9174bc0d9 --- /dev/null +++ b/Source/Core/Common/SocketContext.cpp @@ -0,0 +1,22 @@ +// Copyright 2021 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "Common/SocketContext.h" + +namespace Common +{ +#ifdef _WIN32 +SocketContext::SocketContext() +{ + static_cast(WSAStartup(MAKEWORD(2, 2), &m_data)); +} +SocketContext::~SocketContext() +{ + WSACleanup(); +} +#else +SocketContext::SocketContext() = default; +SocketContext::~SocketContext() = default; +#endif +} // namespace Common -- cgit v1.2.3