| Index: src/platform-linux.cc
|
| ===================================================================
|
| --- src/platform-linux.cc (revision 1531)
|
| +++ src/platform-linux.cc (working copy)
|
| @@ -662,14 +662,8 @@
|
| }
|
| explicit LinuxSocket(int socket): socket_(socket) { }
|
|
|
| + virtual ~LinuxSocket() { Close(); }
|
|
|
| - virtual ~LinuxSocket() {
|
| - if (IsValid()) {
|
| - // Close socket.
|
| - close(socket_);
|
| - }
|
| - }
|
| -
|
| // Server initialization.
|
| bool Bind(const int port);
|
| bool Listen(int backlog) const;
|
| @@ -678,6 +672,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;
|
| @@ -753,6 +750,17 @@
|
| }
|
|
|
|
|
| +bool LinuxSocket::Close() {
|
| + if (IsValid()) {
|
| + // Close socket.
|
| + int status = close(socket_);
|
| + socket_ = -1;
|
| + return status == 0;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +
|
| int LinuxSocket::Send(const char* data, int len) const {
|
| int status = send(socket_, data, len, 0);
|
| return status;
|
|
|