diff --git a/mc_buffer.cpp b/mc_buffer.cpp index 51b41d5..cf9c3bc 100644 --- a/mc_buffer.cpp +++ b/mc_buffer.cpp @@ -87,11 +87,11 @@ void Buffer::setData(const void* data, int bytes) { } const void* Buffer::data() const { - return &data_[0]; + return bytes() == 0 ? NULL : &data_[0]; } void* Buffer::data() { - return &data_[0]; + return bytes() == 0 ? NULL : &data_[0]; } int Buffer::bytes() const { diff --git a/mc_socket.cpp b/mc_socket.cpp index ea2ab86..148832f 100644 --- a/mc_socket.cpp +++ b/mc_socket.cpp @@ -29,16 +29,36 @@ namespace metacall { +namespace { + + // // Constants // -namespace { - - const int SOCKET_INVALID = -1; +// +// Winsock +// + +#ifdef _WIN32 + +struct WsaScope { + WsaScope() { + WSAData data; + WSAStartup(MAKEWORD(2, 2), &data); + } + + ~WsaScope() { + WSACleanup(); + } +} wsa; + +#endif + + } diff --git a/metacall.hpp b/metacall.hpp index 99a47d2..73c5de9 100644 --- a/metacall.hpp +++ b/metacall.hpp @@ -31,6 +31,7 @@ #ifdef _WIN32 #pragma comment(lib, "ws2_32.lib") + #define NOMINMAX #include #else #include