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: runtime/bin/socket_win.cc

Issue 10409051: Make standalone Dart VM run on Windows XP (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review commetns Created 8 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_win.cc
diff --git a/runtime/bin/socket_win.cc b/runtime/bin/socket_win.cc
index d581b8b07e81359912d47c6e593b01e63ccba49c..6dabff24ef382531aeaf3ab0126def5ec1691254 100644
--- a/runtime/bin/socket_win.cc
+++ b/runtime/bin/socket_win.cc
@@ -61,14 +61,20 @@ bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) {
fprintf(stderr, "Error getpeername: %s\n", strerror(errno));
return false;
}
- if (inet_ntop(socket_address.sin_family,
- reinterpret_cast<void *>(&socket_address.sin_addr),
- host,
- INET_ADDRSTRLEN) == NULL) {
- fprintf(stderr, "Error inet_ntop: %s\n", strerror(errno));
+ *port = ntohs(socket_address.sin_port);
+ // Clear the port before calling WSAAddressToString as WSAAddressToString
+ // includes the port in the formatted string.
+ socket_address.sin_port = 0;
+ DWORD len = INET_ADDRSTRLEN;
+ int err = WSAAddressToString(reinterpret_cast<LPSOCKADDR>(&socket_address),
+ sizeof(socket_address),
+ NULL,
+ host,
+ &len);
+ if (err != 0) {
+ fprintf(stderr, "Error WSAAddressToString: %d\n", WSAGetLastError());
return false;
}
- *port = ntohs(socket_address.sin_port);
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698