Index: src/platform-freebsd.cc |
=================================================================== |
--- src/platform-freebsd.cc (revision 1531) |
+++ src/platform-freebsd.cc (working copy) |
@@ -673,14 +673,8 @@ |
} |
explicit FreeBSDSocket(int socket): socket_(socket) { } |
+ virtual ~FreeBSDSocket() { Close(); } |
- virtual ~FreeBSDSocket() { |
- if (IsValid()) { |
- // Close socket. |
- close(socket_); |
- } |
- } |
- |
// Server initialization. |
bool Bind(const int port); |
bool Listen(int backlog) const; |
@@ -689,6 +683,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; |
@@ -764,6 +761,16 @@ |
} |
+bool FreeBSDSocket::Close() { |
+ if (IsValid()) { |
+ // Close socket. |
+ int status = close(socket_); |
+ socket_ = -1; |
+ return status == 0; |
+ } |
+ return true; |
+} |
+ |
int FreeBSDSocket::Send(const char* data, int len) const { |
int status = send(socket_, data, len, 0); |
return status; |