File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 2929#include < boost/thread/thread.hpp>
3030
3131// WIN32 headers included by platform/basic.h
32- #ifndef _WIN32
32+ #if defined(_WIN32)
33+ // Initialize Winsock
34+ struct WinsockInit {
35+ WinsockInit () {
36+
37+ WSADATA wsaData;
38+ int iResult;
39+
40+ iResult = WSAStartup (MAKEWORD (2 ,2 ), &wsaData);
41+ if (iResult != 0 ) {
42+ printf (" WSAStartup failed: %d\n " , iResult);
43+ }
44+ }
45+
46+ ~WinsockInit () { WSACleanup (); }
47+ } winsock_init;
48+ #else
3349 #include < arpa/inet.h>
3450 #include < sys/socket.h>
3551 #include < netdb.h>
@@ -129,8 +145,10 @@ namespace mongo {
129145
130146 void close () {
131147 if (!_closed) {
132- ::close (_fd);
148+ ::shutdown (_fd, 2 );
149+ ::closesocket (_fd);
133150 _closed = true ;
151+ _fd = -1 ;
134152 }
135153 }
136154
You can’t perform that action at this time.
0 commit comments