Index: src/platform-linux.cc |
=================================================================== |
--- src/platform-linux.cc (revision 1538) |
+++ src/platform-linux.cc (working copy) |
@@ -651,9 +651,8 @@ |
socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); |
} |
explicit LinuxSocket(int socket): socket_(socket) { } |
+ virtual ~LinuxSocket() { Shutdown(); } |
- virtual ~LinuxSocket() { Close(); } |
- |
// Server initialization. |
bool Bind(const int port); |
bool Listen(int backlog) const; |
@@ -662,8 +661,8 @@ |
// Client initialization. |
bool Connect(const char* host, const char* port); |
- // Close. |
- bool Close(); |
+ // Shutdown socket for both read and write. |
+ bool Shutdown(); |
// Data Transimission |
int Send(const char* data, int len) const; |
@@ -741,10 +740,11 @@ |
} |
-bool LinuxSocket::Close() { |
+bool LinuxSocket::Shutdown() { |
if (IsValid()) { |
- // Close socket. |
- int status = close(socket_); |
+ // Shutdown socket for both read and write. |
+ int status = shutdown(socket_, SHUT_RDWR); |
+ close(socket_); |
socket_ = -1; |
return status == 0; |
} |