summaryrefslogtreecommitdiff
path: root/chromium/net/tools/flip_server/create_listener.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/net/tools/flip_server/create_listener.h')
-rw-r--r--chromium/net/tools/flip_server/create_listener.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/chromium/net/tools/flip_server/create_listener.h b/chromium/net/tools/flip_server/create_listener.h
new file mode 100644
index 00000000000..4a4a6e16cbd
--- /dev/null
+++ b/chromium/net/tools/flip_server/create_listener.h
@@ -0,0 +1,57 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_TOOLS_FLIP_SERVER_CREATE_LISTENER_H__
+#define NET_TOOLS_FLIP_SERVER_CREATE_LISTENER_H__
+
+#include <iosfwd>
+#include <string>
+
+namespace net {
+
+void SetNonBlocking(int fd);
+
+// Summary:
+// creates a socket for listening, and bind()s and listen()s it.
+// Args:
+// host - hostname or numeric address, or empty-string if you want
+// to bind to listen on all addresses
+// port - a port number or service name. By service name I mean a
+// -real- service name, not a Google service name. I'd suggest
+// you just stick to a numeric representation like "80"
+// is_numeric_host_address -
+// if you know that the host address has already been looked-up,
+// and will be provided in numeric form like "130.207.244.244",
+// then you can set this to true, and it will save you the time
+// of a DNS lookup.
+// backlog - passed into listen. This is the number of pending incoming
+// connections a socket which is listening may have acquired before
+// the OS starts rejecting new incoming connections.
+// reuseaddr - if true sets SO_REUSEADDR on the listening socket
+// reuseport - if true sets SO_REUSEPORT on the listening socket
+// wait_for_iface - A boolean indicating that CreateListeningSocket should
+// block until the interface that it will bind to has been
+// raised. This is intended for HA environments.
+// disable_nagle - if true sets TCP_NODELAY on the listening socket.
+// listen_fd - this will be assigned a positive value if the socket is
+// successfully created, else it will be assigned -1.
+int CreateListeningSocket(const std::string& host,
+ const std::string& port,
+ bool is_numeric_host_address,
+ int backlog,
+ bool reuseaddr,
+ bool reuseport,
+ bool wait_for_iface,
+ bool disable_nagle,
+ int * listen_fd);
+
+int CreateConnectedSocket(int *connect_fd,
+ const std::string& host,
+ const std::string& port,
+ bool is_numeric_host_address,
+ bool disable_nagle);
+} // namespace net
+
+#endif // NET_TOOLS_FLIP_SERVER_CREATE_LISTENER_H__
+