Index: src/platform-win32.cc |
=================================================================== |
--- src/platform-win32.cc (revision 1531) |
+++ src/platform-win32.cc (working copy) |
@@ -1572,12 +1572,7 @@ |
explicit Win32Socket(SOCKET socket): socket_(socket) { } |
- virtual ~Win32Socket() { |
- if (IsValid()) { |
- // Close socket. |
- closesocket(socket_); |
- } |
- } |
+ virtual ~Win32Socket() { Close(); } |
// Server initialization. |
bool Bind(const int port); |
@@ -1587,6 +1582,9 @@ |
// Client initialization. |
bool Connect(const char* host, const char* port); |
+ // Close. |
+ bool Close(); |
+ |
// Data Transimission |
int Send(const char* data, int len) const; |
int Receive(char* data, int len) const; |
@@ -1662,6 +1660,17 @@ |
} |
+bool Win32Socket::Close() { |
+ if (IsValid()) { |
+ // Close socket. |
+ int rc = closesocket(socket_); |
+ socket_ = INVALID_SOCKET; |
+ return rc != SOCKET_ERROR; |
+ } |
+ return true; |
+} |
+ |
+ |
int Win32Socket::Send(const char* data, int len) const { |
int status = send(socket_, data, len, 0); |
return status; |