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

Unified Diff: net/socket/stream_listen_socket.cc

Issue 181063006: Gets the peer address (if available) in server requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Diff upload failed Created 6 years, 10 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/server/http_server.cc ('K') | « net/socket/stream_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/socket/stream_listen_socket.cc
diff --git a/net/socket/stream_listen_socket.cc b/net/socket/stream_listen_socket.cc
index 960991b7c6da0be28862155cccf74cea0e56ffb6..e12631f18959342cfc277521fae430f46e8d67d5 100644
--- a/net/socket/stream_listen_socket.cc
+++ b/net/socket/stream_listen_socket.cc
@@ -100,6 +100,17 @@ int StreamListenSocket::GetLocalAddress(IPEndPoint* address) {
return OK;
}
+int StreamListenSocket::GetPeerAddress(IPEndPoint* address) {
+ SockaddrStorage storage;
+ if (getpeername(socket_, storage.addr, &storage.addr_len)) {
+ return MapSystemError(errno);
Ryan Sleevi 2014/03/11 01:32:43 |errno| won't be set on Win - it would be WSAGetLa
gunsch 2014/03/17 16:57:15 Done.
+ } else if (!address->FromSockAddr(storage.addr, storage.addr_len)) {
+ return ERR_FAILED;
Ryan Sleevi 2014/03/11 01:32:43 ERR_ADDRESS_INVALID
gunsch 2014/03/17 16:57:15 Hm, why ERR_ADDRESS_INVALID? In GetLocalAddress ab
Ryan Sleevi 2014/03/17 19:47:22 Matches the TCPClientSocket. I suspect the UDPCli
+ } else {
+ return OK;
Ryan Sleevi 2014/03/11 01:32:43 don't use else after return statements if (getpee
gunsch 2014/03/17 16:57:15 Done.
+ }
+}
+
SocketDescriptor StreamListenSocket::AcceptSocket() {
SocketDescriptor conn = HANDLE_EINTR(accept(socket_, NULL, NULL));
if (conn == kInvalidSocket)
« net/server/http_server.cc ('K') | « net/socket/stream_listen_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698