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

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

Issue 10014037: Fix win32 Socket test errors (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_macos.h ('k') | runtime/bin/socket_win.h » ('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) 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 <arpa/inet.h>
6 #include <errno.h> 5 #include <errno.h>
7 #include <netdb.h>
8 #include <stdio.h> 6 #include <stdio.h>
9 #include <stdlib.h> 7 #include <stdlib.h>
10 #include <string.h> 8 #include <string.h>
11 #include <sys/socket.h>
12 #include <unistd.h> 9 #include <unistd.h>
13 10
14 #include "bin/fdutils.h" 11 #include "bin/fdutils.h"
15 #include "bin/socket.h" 12 #include "bin/socket.h"
16 13
17 14
18 bool Socket::Initialize() { 15 bool Socket::Initialize() {
19 // Nothing to do on Mac OS. 16 // Nothing to do on Mac OS.
20 return true; 17 return true;
21 } 18 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 reinterpret_cast<struct sockaddr *>(&socket_address), 93 reinterpret_cast<struct sockaddr *>(&socket_address),
97 &size))) { 94 &size))) {
98 fprintf(stderr, "Error getsockname: %s\n", strerror(errno)); 95 fprintf(stderr, "Error getsockname: %s\n", strerror(errno));
99 return 0; 96 return 0;
100 } 97 }
101 return ntohs(socket_address.sin_port); 98 return ntohs(socket_address.sin_port);
102 } 99 }
103 100
104 101
105 bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) { 102 bool Socket::GetRemotePeer(intptr_t fd, char *host, intptr_t *port) {
106 ASSERT(DART_INET_ADDRSTRLEN >= INET_ADDRSTRLEN);
107 ASSERT(fd >= 0); 103 ASSERT(fd >= 0);
108 struct sockaddr_in socket_address; 104 struct sockaddr_in socket_address;
109 socklen_t size = sizeof(socket_address); 105 socklen_t size = sizeof(socket_address);
110 if (TEMP_FAILURE_RETRY( 106 if (TEMP_FAILURE_RETRY(
111 getpeername(fd, 107 getpeername(fd,
112 reinterpret_cast<struct sockaddr *>(&socket_address), 108 reinterpret_cast<struct sockaddr *>(&socket_address),
113 &size))) { 109 &size))) {
114 fprintf(stderr, "Error getpeername: %s\n", strerror(errno)); 110 fprintf(stderr, "Error getpeername: %s\n", strerror(errno));
115 return false; 111 return false;
116 } 112 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // error. We got woken up from the poll on the listening socket, 221 // error. We got woken up from the poll on the listening socket,
226 // but there is no connection ready to be accepted. 222 // but there is no connection ready to be accepted.
227 ASSERT(kTemporaryFailure != -1); 223 ASSERT(kTemporaryFailure != -1);
228 socket = kTemporaryFailure; 224 socket = kTemporaryFailure;
229 } 225 }
230 } else { 226 } else {
231 FDUtils::SetNonBlocking(socket); 227 FDUtils::SetNonBlocking(socket);
232 } 228 }
233 return socket; 229 return socket;
234 } 230 }
OLDNEW
« no previous file with comments | « runtime/bin/socket_macos.h ('k') | runtime/bin/socket_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698