OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_TOOLS_FLIP_SERVER_TCP_SOCKET_UTIL_H_ | |
6 #define NET_TOOLS_FLIP_SERVER_TCP_SOCKET_UTIL_H_ | |
7 | |
8 #include <string> | |
9 | |
10 namespace net { | |
11 | |
12 // Summary: | |
13 // creates a socket for listening, and bind()s and listen()s it. | |
14 // Args: | |
15 // host - hostname or numeric address, or empty-string if you want | |
16 // to bind to listen on all addresses | |
17 // port - a port number or service name. By service name I mean a | |
18 // -real- service name, not a Google service name. I'd suggest | |
19 // you just stick to a numeric representation like "80" | |
20 // is_numeric_host_address - | |
21 // if you know that the host address has already been looked-up, | |
22 // and will be provided in numeric form like "130.207.244.244", | |
23 // then you can set this to true, and it will save you the time | |
24 // of a DNS lookup. | |
25 // backlog - passed into listen. This is the number of pending incoming | |
26 // connections a socket which is listening may have acquired before | |
27 // the OS starts rejecting new incoming connections. | |
28 // reuseaddr - if true sets SO_REUSEADDR on the listening socket | |
29 // reuseport - if true sets SO_REUSEPORT on the listening socket | |
30 // wait_for_iface - A boolean indicating that CreateTCPServerSocket should | |
31 // block until the interface that it will bind to has been | |
32 // raised. This is intended for HA environments. | |
33 // disable_nagle - if true sets TCP_NODELAY on the listening socket. | |
34 // listen_fd - this will be assigned a positive value if the socket is | |
35 // successfully created, else it will be assigned -1. | |
36 int CreateTCPServerSocket(const std::string& host, | |
37 const std::string& port, | |
38 bool is_numeric_host_address, | |
39 int backlog, | |
40 bool reuseaddr, | |
41 bool reuseport, | |
42 bool wait_for_iface, | |
43 bool disable_nagle, | |
44 int* listen_fd); | |
45 | |
46 int CreateTCPClientSocket(const std::string& host, | |
47 const std::string& port, | |
48 bool is_numeric_host_address, | |
49 bool disable_nagle, | |
50 int* connect_fd); | |
51 | |
52 } // namespace net | |
53 | |
54 #endif // NET_TOOLS_FLIP_SERVER_TCP_SOCKET_UTIL_H_ | |
OLD | NEW |