-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1472 from dgelessus/dont_include_winsock_everywhere
Include Winsock header only where it's actually used
- Loading branch information
Showing
4 changed files
with
15 additions
and
13 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 |
---|---|---|
|
@@ -49,8 +49,8 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
/** \file hsWindows.h | ||
* \brief Pulls in Windows core headers | ||
* | ||
* This file pulls in the core Windows headers and Winsock2. It is separate from | ||
* HeadSpin.h to improve build times and to facillitate adding precompiled headers. | ||
* This file pulls in the core Windows headers. It is separate from HeadSpin.h | ||
* to improve build times and to facilitate adding precompiled headers. | ||
* You should avoid including this header from other headers! | ||
*/ | ||
|
||
|
@@ -75,7 +75,6 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
|
||
# define WIN32_LEAN_AND_MEAN | ||
# include <windows.h> | ||
# include <ws2tcpip.h> // Pulls in WinSock 2 for us | ||
|
||
// This needs to be after #include <windows.h>, since it also includes windows.h | ||
# ifdef USE_VLD | ||
|
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 |
---|---|---|
|
@@ -46,10 +46,6 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
#include "plNetAddress.h" | ||
#include "pnNetCommon.h" | ||
|
||
#ifndef AF_INET | ||
# define AF_INET 2 | ||
#endif | ||
|
||
ST::string plNetAddress::GetHostString() const | ||
{ | ||
return pnNetCommon::GetTextAddr(fHost); | ||
|
@@ -95,7 +91,7 @@ void plNetAddress::Read(hsStream * s) | |
fHost = s->ReadLE32(); | ||
fPort = s->ReadLE16(); | ||
|
||
// Family is always AF_INET | ||
// Family is always kInet | ||
(void) s->ReadLE16(); | ||
} | ||
|
||
|
@@ -104,6 +100,5 @@ void plNetAddress::Write(hsStream * s) | |
s->WriteLE32(fHost); | ||
s->WriteLE16(fPort); | ||
|
||
// Family is always AF_INET | ||
s->WriteLE16((uint16_t)AF_INET); | ||
s->WriteLE16(static_cast<uint16_t>(Family::kInet)); | ||
} |
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 |
---|---|---|
|
@@ -61,6 +61,12 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
*/ | ||
class plNetAddress | ||
{ | ||
// This is used in the Read/Write format and so must not use the potentially OS-dependent AF_* constants. | ||
enum class Family : uint16_t | ||
{ | ||
kInet = 2, // matches AF_INET from Winsock <ws2def.h> | ||
}; | ||
|
||
uint32_t fHost; | ||
uint16_t fPort; | ||
|
||
|
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 |
---|---|---|
|
@@ -41,14 +41,16 @@ You can contact Cyan Worlds, Inc. by email [email protected] | |
*==LICENSE==*/ | ||
#include <string> | ||
#include "pnNetCommon.h" | ||
#include "hsWindows.h" | ||
|
||
#if HS_BUILD_FOR_UNIX | ||
#if defined(HS_BUILD_FOR_UNIX) | ||
# include <sys/socket.h> | ||
# include <netinet/in.h> | ||
# include <arpa/inet.h> | ||
# include <netdb.h> | ||
#elif !defined(HS_BUILD_FOR_WIN32) | ||
#elif defined(HS_BUILD_FOR_WIN32) | ||
#include "hsWindows.h" | ||
#include <ws2tcpip.h> | ||
#else | ||
#error "Not implemented for this platform" | ||
#endif | ||
|
||
|