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