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

Unified Diff: runtime/bin/socket_macos.cc

Issue 9963053: Add remotePort getter to Socket. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
===================================================================
--- runtime/bin/socket_macos.cc (revision 6086)
+++ runtime/bin/socket_macos.cc (working copy)
@@ -102,6 +102,21 @@
}
+intptr_t Socket::GetRemotePort(intptr_t fd) {
+ ASSERT(fd >= 0);
+ struct sockaddr_in socket_address;
+ socklen_t size = sizeof(socket_address);
+ if (TEMP_FAILURE_RETRY(
+ getpeername(fd,
+ reinterpret_cast<struct sockaddr *>(&socket_address),
+ &size))) {
+ fprintf(stderr, "Error getpeername: %s\n", strerror(errno));
+ return 0;
+ }
+ return ntohs(socket_address.sin_port);
+}
+
+
void Socket::GetError(intptr_t fd, OSError* os_error) {
int len = sizeof(errno);
getsockopt(fd,
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698