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

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, 2 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
« net/base/tcp_listen_socket.h ('K') | « net/base/tcp_listen_socket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tcp_listen_socket.cc
===================================================================
--- net/base/tcp_listen_socket.cc (revision 163266)
+++ net/base/tcp_listen_socket.cc (working copy)
@@ -76,6 +76,25 @@
return s;
}
+int TCPListenSocket::GetBindedPort(SocketDescriptor s) {
Mark Seaborn 2012/10/23 01:14:50 Should the return type be uint16 to match NetToHos
halyavin 2012/10/23 11:59:29 port numbers are generally saved in int in Chrome.
+ 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";
+#if defined(OS_WIN)
+ closesocket(s);
+#elif defined(OS_POSIX)
+ close(s);
+#endif
+ return -1;
+ }
+ return base::NetToHost16(addr.sin_port);
+}
+
void TCPListenSocket::Accept() {
SocketDescriptor conn = AcceptSocket();
if (conn == kInvalidSocket)
« net/base/tcp_listen_socket.h ('K') | « net/base/tcp_listen_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698