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

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

Issue 11566007: Fix extraction of error messages on Windows from getaddrinfo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "bin/builtin.h" 5 #include "bin/builtin.h"
6 #include "bin/eventhandler.h" 6 #include "bin/eventhandler.h"
7 #include "bin/log.h" 7 #include "bin/log.h"
8 #include "bin/socket.h" 8 #include "bin/socket.h"
9 9
10 bool Socket::Initialize() { 10 bool Socket::Initialize() {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // Perform a name lookup for an IPv4 address. 177 // Perform a name lookup for an IPv4 address.
178 struct addrinfo hints; 178 struct addrinfo hints;
179 memset(&hints, 0, sizeof(hints)); 179 memset(&hints, 0, sizeof(hints));
180 hints.ai_family = AF_INET; 180 hints.ai_family = AF_INET;
181 hints.ai_socktype = SOCK_STREAM; 181 hints.ai_socktype = SOCK_STREAM;
182 hints.ai_protocol = IPPROTO_TCP; 182 hints.ai_protocol = IPPROTO_TCP;
183 struct addrinfo* info = NULL; 183 struct addrinfo* info = NULL;
184 int status = getaddrinfo(host, 0, &hints, &info); 184 int status = getaddrinfo(host, 0, &hints, &info);
185 if (status != 0) { 185 if (status != 0) {
186 ASSERT(*os_error == NULL); 186 ASSERT(*os_error == NULL);
187 *os_error = new OSError(status, 187 DWORD error_code = WSAGetLastError();
188 gai_strerror(status), 188 SetLastError(error_code);
189 OSError::kGetAddressInfo); 189 *os_error = new OSError();
190 return NULL; 190 return NULL;
191 } 191 }
192 // Convert the address into IPv4 dotted decimal notation. 192 // Convert the address into IPv4 dotted decimal notation.
193 char* buffer = reinterpret_cast<char*>(malloc(INET_ADDRSTRLEN)); 193 char* buffer = reinterpret_cast<char*>(malloc(INET_ADDRSTRLEN));
194 sockaddr_in *sockaddr = reinterpret_cast<sockaddr_in *>(info->ai_addr); 194 sockaddr_in *sockaddr = reinterpret_cast<sockaddr_in *>(info->ai_addr);
195 195
196 // Clear the port before calling WSAAddressToString as WSAAddressToString 196 // Clear the port before calling WSAAddressToString as WSAAddressToString
197 // includes the port in the formatted string. 197 // includes the port in the formatted string.
198 DWORD len = INET_ADDRSTRLEN; 198 DWORD len = INET_ADDRSTRLEN;
199 int err = WSAAddressToString(reinterpret_cast<LPSOCKADDR>(sockaddr), 199 int err = WSAAddressToString(reinterpret_cast<LPSOCKADDR>(sockaddr),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (status == SOCKET_ERROR) { 254 if (status == SOCKET_ERROR) {
255 DWORD rc = WSAGetLastError(); 255 DWORD rc = WSAGetLastError();
256 closesocket(s); 256 closesocket(s);
257 SetLastError(rc); 257 SetLastError(rc);
258 return -1; 258 return -1;
259 } 259 }
260 260
261 ListenSocket* listen_socket = new ListenSocket(s); 261 ListenSocket* listen_socket = new ListenSocket(s);
262 return reinterpret_cast<intptr_t>(listen_socket); 262 return reinterpret_cast<intptr_t>(listen_socket);
263 } 263 }
OLDNEW
« 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