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

Side by Side Diff: dart/runtime/bin/socket_win.cc

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/bin/socket_patch.dart ('k') | dart/runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/eventhandler.h" 9 #include "bin/eventhandler.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 if (getsockname(socket_handle->socket(), 78 if (getsockname(socket_handle->socket(),
79 &raw.addr, 79 &raw.addr,
80 &size) == SOCKET_ERROR) { 80 &size) == SOCKET_ERROR) {
81 Log::PrintErr("Error getsockname: %d\n", WSAGetLastError()); 81 Log::PrintErr("Error getsockname: %d\n", WSAGetLastError());
82 return 0; 82 return 0;
83 } 83 }
84 return SocketAddress::GetAddrPort(&raw); 84 return SocketAddress::GetAddrPort(&raw);
85 } 85 }
86 86
87 87
88 bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { 88 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) {
89 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket()); 89 ASSERT(reinterpret_cast<Handle*>(fd)->is_socket());
90 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd); 90 SocketHandle* socket_handle = reinterpret_cast<SocketHandle*>(fd);
91 RawAddr raw; 91 RawAddr raw;
92 socklen_t size = sizeof(raw); 92 socklen_t size = sizeof(raw);
93 if (getpeername(socket_handle->socket(), 93 if (getpeername(socket_handle->socket(),
94 &raw.addr, 94 &raw.addr,
95 &size)) { 95 &size)) {
96 Log::PrintErr("Error getpeername: %d\n", WSAGetLastError()); 96 Log::PrintErr("Error getpeername: %d\n", WSAGetLastError());
97 return false; 97 return NULL;
98 } 98 }
99 *port = SocketAddress::GetAddrPort(&raw); 99 *port = SocketAddress::GetAddrPort(&raw);
100 // Clear the port before calling WSAAddressToString as WSAAddressToString 100 // Clear the port before calling WSAAddressToString as WSAAddressToString
101 // includes the port in the formatted string. 101 // includes the port in the formatted string.
102 SocketAddress::SetAddrPort(&raw, 0); 102 SocketAddress::SetAddrPort(&raw, 0);
103 DWORD len = INET6_ADDRSTRLEN; 103 return new SocketAddress(&raw.addr);
104 int err = WSAAddressToStringA(&raw.addr,
105 sizeof(raw),
106 NULL,
107 host,
108 &len);
109 if (err != 0) {
110 Log::PrintErr("Error WSAAddressToString: %d\n", WSAGetLastError());
111 return false;
112 }
113 return true;
114 } 104 }
115 105
116 106
117 intptr_t Socket::Create(RawAddr addr) { 107 intptr_t Socket::Create(RawAddr addr) {
118 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0); 108 SOCKET s = socket(addr.ss.ss_family, SOCK_STREAM, 0);
119 if (s == INVALID_SOCKET) { 109 if (s == INVALID_SOCKET) {
120 return -1; 110 return -1;
121 } 111 }
122 112
123 linger l; 113 linger l;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 IPPROTO_TCP, 429 IPPROTO_TCP,
440 TCP_NODELAY, 430 TCP_NODELAY,
441 reinterpret_cast<char *>(&on), 431 reinterpret_cast<char *>(&on),
442 sizeof(on)) == 0; 432 sizeof(on)) == 0;
443 } 433 }
444 434
445 } // namespace bin 435 } // namespace bin
446 } // namespace dart 436 } // namespace dart
447 437
448 #endif // defined(TARGET_OS_WINDOWS) 438 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « dart/runtime/bin/socket_patch.dart ('k') | dart/runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698