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

Unified Diff: runtime/bin/socket_win.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_macos.cc ('k') | tests/standalone/src/io/SocketPortTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_win.cc
===================================================================
--- runtime/bin/socket_win.cc (revision 6086)
+++ runtime/bin/socket_win.cc (working copy)
@@ -54,6 +54,21 @@
}
+intptr_t Socket::GetRemotePort(intptr_t fd) {
+ ASSERT(reinterpret_cast<Handle*>(fd)->is_socket());
+ SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd);
+ struct sockaddr_in socket_address;
+ socklen_t size = sizeof(socket_address);
+ if (getpeername(socket_handle->socket(),
+ reinterpret_cast<struct sockaddr *>(&socket_address),
+ &size)) {
+ fprintf(stderr, "Error getpeername: %s\n", strerror(errno));
+ return 0;
+ }
+ return ntohs(socket_address.sin_port);
+}
+
+
intptr_t Socket::CreateConnect(const char* host, const intptr_t port) {
SOCKET s = socket(AF_INET, SOCK_STREAM, 0);
if (s == INVALID_SOCKET) {
« no previous file with comments | « runtime/bin/socket_macos.cc ('k') | tests/standalone/src/io/SocketPortTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698