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

Unified Diff: src/trusted/debug_stub/transport_common.cc

Issue 206493005: Provide chrome the option of learning the debug stub port chosen by nacl. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: review fixes Created 6 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/trusted/debug_stub/transport.h ('k') | src/trusted/service_runtime/sel_ldr.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/debug_stub/transport_common.cc
diff --git a/src/trusted/debug_stub/transport_common.cc b/src/trusted/debug_stub/transport_common.cc
index d81612182cdd4de4854536aaeba65a41fbcb0100..32cb83191670b323901c126a5ad3015af98ca07b 100644
--- a/src/trusted/debug_stub/transport_common.cc
+++ b/src/trusted/debug_stub/transport_common.cc
@@ -22,9 +22,11 @@
using gdb_rsp::stringvec;
using gdb_rsp::StringSplit;
-namespace port {
-
+#if NACL_WINDOWS
typedef int socklen_t;
+#endif
+
+namespace port {
class Transport : public ITransport {
public:
@@ -423,4 +425,17 @@ ITransport *SocketBinding::AcceptConnection() {
return NULL;
}
+uint16_t SocketBinding::GetBoundPort() {
+ struct sockaddr_in saddr;
+ struct sockaddr *psaddr = reinterpret_cast<struct sockaddr *>(&saddr);
+ // Clearing sockaddr_in first appears to be necessary on Mac OS X.
+ memset(&saddr, 0, sizeof(saddr));
+ socklen_t addrlen = static_cast<socklen_t>(sizeof(saddr));
+ if (::getsockname(socket_handle_, psaddr, &addrlen)) {
+ NaClLog(LOG_ERROR, "Failed to retrieve bound address.\n");
+ return 0;
+ }
+ return ntohs(saddr.sin_port);
+}
+
} // namespace port
« no previous file with comments | « src/trusted/debug_stub/transport.h ('k') | src/trusted/service_runtime/sel_ldr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698