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

Side by Side Diff: net/tools/flip_server/tcp_socket_util.cc

Issue 1684443002: flip_server: rename create_listener.* for clarity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « net/tools/flip_server/tcp_socket_util.h ('k') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/tools/flip_server/create_listener.h" 5 #include "net/tools/flip_server/tcp_socket_util.h"
6 6
7 #include <arpa/inet.h> 7 #include <arpa/inet.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <netdb.h> 9 #include <netdb.h>
10 #include <netinet/in.h> 10 #include <netinet/in.h>
11 #include <netinet/tcp.h> 11 #include <netinet/tcp.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <string.h> 13 #include <string.h>
14 #include <sys/socket.h> 14 #include <sys/socket.h>
15 #include <sys/types.h> 15 #include <sys/types.h>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 rc = setsockopt( 63 rc = setsockopt(
64 fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&on), sizeof(on)); 64 fd, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char*>(&on), sizeof(on));
65 if (rc < 0) { 65 if (rc < 0) {
66 close(fd); 66 close(fd);
67 LOG(FATAL) << "setsockopt() TCP_NODELAY: failed on fd " << fd; 67 LOG(FATAL) << "setsockopt() TCP_NODELAY: failed on fd " << fd;
68 return 0; 68 return 0;
69 } 69 }
70 return 1; 70 return 1;
71 } 71 }
72 72
73 // see header for documentation of this function. 73 int CreateTCPServerSocket(const std::string& host,
74 int CreateListeningSocket(const std::string& host,
75 const std::string& port, 74 const std::string& port,
76 bool is_numeric_host_address, 75 bool is_numeric_host_address,
77 int backlog, 76 int backlog,
78 bool reuseaddr, 77 bool reuseaddr,
79 bool reuseport, 78 bool reuseport,
80 bool wait_for_iface, 79 bool wait_for_iface,
81 bool disable_nagle, 80 bool disable_nagle,
82 int* listen_fd) { 81 int* listen_fd) {
83 // start out by assuming things will fail. 82 // start out by assuming things will fail.
84 *listen_fd = -1; 83 *listen_fd = -1;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 "error, and exiting\n"; 199 "error, and exiting\n";
201 } 200 }
202 } 201 }
203 202
204 // If we've gotten to here, Yeay! Success! 203 // If we've gotten to here, Yeay! Success!
205 *listen_fd = sock; 204 *listen_fd = sock;
206 205
207 return 0; 206 return 0;
208 } 207 }
209 208
210 int CreateConnectedSocket(int* connect_fd, 209 int CreateTCPClientSocket(int* connect_fd,
211 const std::string& host, 210 const std::string& host,
212 const std::string& port, 211 const std::string& port,
213 bool is_numeric_host_address, 212 bool is_numeric_host_address,
214 bool disable_nagle) { 213 bool disable_nagle) {
215 const char* node = NULL; 214 const char* node = NULL;
216 const char* service = NULL; 215 const char* service = NULL;
217 216
218 *connect_fd = -1; 217 *connect_fd = -1;
219 if (!host.empty()) 218 if (!host.empty())
220 node = host.c_str(); 219 node = host.c_str();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 ret_val = 1; 271 ret_val = 1;
273 } 272 }
274 273
275 // If we've gotten to here, Yeay! Success! 274 // If we've gotten to here, Yeay! Success!
276 *connect_fd = sock; 275 *connect_fd = sock;
277 276
278 return ret_val; 277 return ret_val;
279 } 278 }
280 279
281 } // namespace net 280 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/flip_server/tcp_socket_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698