| Index: src/platform-freebsd.cc
|
| ===================================================================
|
| --- src/platform-freebsd.cc (revision 1538)
|
| +++ src/platform-freebsd.cc (working copy)
|
| @@ -650,9 +650,8 @@
|
| socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
| }
|
| explicit FreeBSDSocket(int socket): socket_(socket) { }
|
| + virtual ~FreeBSDSocket() { Shutdown(); }
|
|
|
| - virtual ~FreeBSDSocket() { Close(); }
|
| -
|
| // Server initialization.
|
| bool Bind(const int port);
|
| bool Listen(int backlog) const;
|
| @@ -661,8 +660,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;
|
| @@ -740,16 +739,18 @@
|
| }
|
|
|
|
|
| -bool FreeBSDSocket::Close() {
|
| +bool FreeBSDSocket::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;
|
| }
|
| return true;
|
| }
|
|
|
| +
|
| int FreeBSDSocket::Send(const char* data, int len) const {
|
| int status = send(socket_, data, len, 0);
|
| return status;
|
|
|