diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2009-01-14 21:09:21 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2009-01-14 21:09:21 +0000 |
| commit | ef2f33c700a9f559648089a5314638f9c73d3589 (patch) | |
| tree | 1734cf5b726b482a6d78c21e115bf55b68dcfa90 | |
| parent | b49973db8489f02e10e3475b6a8a199d919a6efa (diff) | |
| download | libbu++-ef2f33c700a9f559648089a5314638f9c73d3589.tar.gz libbu++-ef2f33c700a9f559648089a5314638f9c73d3589.tar.bz2 libbu++-ef2f33c700a9f559648089a5314638f9c73d3589.tar.xz libbu++-ef2f33c700a9f559648089a5314638f9c73d3589.zip | |
Gettin' closer.
Diffstat (limited to '')
| -rw-r--r-- | src/socket.cpp | 6 | ||||
| -rw-r--r-- | src/win32_compatibility.cpp | 10 | ||||
| -rw-r--r-- | src/win32_compatibility.h | 15 |
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 | ||
| 41 | Bu::Socket::Socket( const Bu::FString &sAddr, int nPort, int nTimeout ) | 44 | Bu::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 | ||
| 353 | DynamicWinsock2::Winsock2::Winsock2() | ||
| 354 | { | ||
| 355 | DynamicWinsock2::WSAStartup( MAKEWORD(2, 2), &wsaData ); | ||
| 356 | } | ||
| 357 | |||
| 358 | DynamicWinsock2::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 */ |
