Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1206)

Unified Diff: src/platform-macos.cc

Issue 42330: Add a close method to sockets (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
===================================================================
--- src/platform-macos.cc (revision 1531)
+++ src/platform-macos.cc (working copy)
@@ -599,14 +599,8 @@
}
explicit MacOSSocket(int socket): socket_(socket) { }
+ virtual ~MacOSSocket() { Close(); }
- virtual ~MacOSSocket() {
- if (IsValid()) {
- // Close socket.
- close(socket_);
- }
- }
-
// Server initialization.
bool Bind(const int port);
bool Listen(int backlog) const;
@@ -615,6 +609,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;
@@ -696,6 +693,17 @@
}
+bool MacOSSocket::Close() {
+ if (IsValid()) {
+ // Close socket.
+ int status = close(socket_);
+ socket_ = -1;
+ return status == 0;
+ }
+ return true;
+}
+
+
int MacOSSocket::Send(const char* data, int len) const {
int status = send(socket_, data, len, 0);
return status;
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698