-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 8014f79.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include "gloo/common/win.h" | ||
#include "gloo/common/logging.h" | ||
|
||
#include <mutex> | ||
|
||
namespace gloo { | ||
|
||
static std::once_flag init_flag; | ||
|
||
// The WSAStartup function must be the first Windows Sockets function | ||
// called by an application or DLL. | ||
// https://docs.microsoft.com/ru-ru/windows/win32/api/winsock/nf-winsock-wsastartup | ||
|
||
void init_winsock() { | ||
std::call_once(init_flag, []() { | ||
WSADATA wsa_data; | ||
int res; | ||
res = WSAStartup(MAKEWORD(2, 2), &wsa_data); | ||
if (res != 0) { | ||
GLOO_ENFORCE(false, "WSAStartup failed: ", res); | ||
} | ||
}); | ||
} | ||
|
||
} // namespace gloo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <winsock2.h> | ||
|
||
#pragma comment(lib, "Ws2_32.lib") | ||
|
||
namespace gloo { | ||
|
||
void init_winsock(); | ||
|
||
} // namespace gloo |