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

Unified Diff: net/base/tcp_listen_socket.cc

Issue 11236025: Test that debug stub works with browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: rebase Created 8 years 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
Index: net/base/tcp_listen_socket.cc
===================================================================
--- net/base/tcp_listen_socket.cc (revision 170891)
+++ net/base/tcp_listen_socket.cc (working copy)
@@ -76,6 +76,28 @@
return s;
}
+SocketDescriptor TCPListenSocket::CreateAndBindAnyPort(const std::string& ip,
Mark Seaborn 2012/12/04 21:46:42 Nit: s/std::string/string/ to match the rest of th
halyavin 2012/12/05 10:05:57 Done.
+ int* port) {
+ SocketDescriptor s = CreateAndBind(ip, 0);
+ sockaddr_in addr;
+ socklen_t addr_size = sizeof(addr);
+ bool failed = getsockname(s, (struct sockaddr *) &addr, &addr_size) != 0;
+ if (addr_size != sizeof(addr)) {
+ failed = true;
+ }
+ if (failed) {
+ LOG(ERROR) << "Could not determine binded port, getsockname() failed";
Mark Seaborn 2012/12/04 21:46:42 'binded' -> 'bound'
halyavin 2012/12/05 10:05:57 Done.
+#if defined(OS_WIN)
+ closesocket(s);
+#elif defined(OS_POSIX)
+ close(s);
+#endif
+ return kInvalidSocket;
+ }
+ *port = base::NetToHost16(addr.sin_port);
+ return s;
+}
+
void TCPListenSocket::Accept() {
SocketDescriptor conn = AcceptSocket();
if (conn == kInvalidSocket)

Powered by Google App Engine
This is Rietveld 408576698