fixes for windows

This commit is contained in:
unknown 2011-09-04 11:14:55 -07:00
parent 30a41a4315
commit 9ec36cae77
3 changed files with 26 additions and 5 deletions

View File

@ -87,11 +87,11 @@ void Buffer::setData(const void* data, int bytes) {
} }
const void* Buffer::data() const { const void* Buffer::data() const {
return &data_[0]; return bytes() == 0 ? NULL : &data_[0];
} }
void* Buffer::data() { void* Buffer::data() {
return &data_[0]; return bytes() == 0 ? NULL : &data_[0];
} }
int Buffer::bytes() const { int Buffer::bytes() const {

View File

@ -29,16 +29,36 @@
namespace metacall { namespace metacall {
namespace {
// //
// Constants // Constants
// //
namespace {
const int SOCKET_INVALID = -1; const int SOCKET_INVALID = -1;
//
// Winsock
//
#ifdef _WIN32
struct WsaScope {
WsaScope() {
WSAData data;
WSAStartup(MAKEWORD(2, 2), &data);
}
~WsaScope() {
WSACleanup();
}
} wsa;
#endif
} }

View File

@ -31,6 +31,7 @@
#ifdef _WIN32 #ifdef _WIN32
#pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "ws2_32.lib")
#define NOMINMAX
#include <ws2tcpip.h> #include <ws2tcpip.h>
#else #else
#include <sys/socket.h> #include <sys/socket.h>