aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/socket.cpp6
-rw-r--r--src/win32_compatibility.cpp10
-rw-r--r--src/win32_compatibility.h15
3 files changed, 30 insertions, 1 deletions
diff --git a/src/socket.cpp b/src/socket.cpp
index 3870a59..3458b45 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -35,11 +35,17 @@ Bu::Socket::Socket( int nSocket ) :
35 nSocket( nSocket ), 35 nSocket( nSocket ),
36 bActive( true ) 36 bActive( true )
37{ 37{
38#ifdef WIN32
39 DynamicWinsock32::Winsock2::getInstance();
40#endif
38 setAddress(); 41 setAddress();
39} 42}
40 43
41Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) 44Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout )
42{ 45{
46#ifdef WIN32
47 DynamicWinsock32::Winsock2::getInstance();
48#endif
43 bActive = false; 49 bActive = false;
44 50
45 /* Create the socket. */ 51 /* Create the socket. */
diff --git a/src/win32_compatibility.cpp b/src/win32_compatibility.cpp
index 083925b..e7710e5 100644
--- a/src/win32_compatibility.cpp
+++ b/src/win32_compatibility.cpp
@@ -350,5 +350,15 @@ int DynamicWinsock2::DYN_FD_ISSET(SOCKET s, fd_set *set)
350 return out; 350 return out;
351} 351}
352 352
353DynamicWinsock2::Winsock2::Winsock2()
354{
355 DynamicWinsock2::WSAStartup( MAKEWORD(2, 2), &wsaData );
356}
357
358DynamicWinsock2::Winsock2::~Winsock2()
359{
360 DynamicWinsock2::WSACleanup();
361}
362
353#endif 363#endif
354 364
diff --git a/src/win32_compatibility.h b/src/win32_compatibility.h
index 72cb4f7..2fe740a 100644
--- a/src/win32_compatibility.h
+++ b/src/win32_compatibility.h
@@ -24,7 +24,8 @@ extern "C"
24} 24}
25#endif 25#endif
26 26
27#include "fstring.h" 27#include "bu/fstring.h"
28#include "bu/singleton.h"
28 29
29#ifndef TEMP_FAILURE_RETRY 30#ifndef TEMP_FAILURE_RETRY
30#define TEMP_FAILURE_RETRY(expression) \ 31#define TEMP_FAILURE_RETRY(expression) \
@@ -65,6 +66,18 @@ namespace DynamicWinsock2
65 int recv( SOCKET s, char *buf, int len, int flags ); 66 int recv( SOCKET s, char *buf, int len, int flags );
66 int send( SOCKET s, const char *buf, int len, int flags ); 67 int send( SOCKET s, const char *buf, int len, int flags );
67 int DYN_FD_ISSET(SOCKET s, fd_set *set); 68 int DYN_FD_ISSET(SOCKET s, fd_set *set);
69
70 class Winsock2 : public Bu::Singleton<Winsock2>
71 {
72 friend class Bu::Singleton<Winsock2>;
73 private:
74 Winsock2();
75 virtual ~Winsock2();
76
77 WSADATA wsaData;
78
79 public:
80 }
68}; 81};
69 82
70#endif /* WIN32 */ 83#endif /* WIN32 */