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

Unified Diff: net/web2socket_proxy/web2socket_main.cc

Issue 5484001: Web2socket proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix for signed/unsigned confusion + cosmetic Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/web2socket_proxy/web2socket_conn.cc ('k') | net/web2socket_proxy/web2socket_serv.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/web2socket_proxy/web2socket_main.cc
diff --git a/net/web2socket_proxy/web2socket_main.cc b/net/web2socket_proxy/web2socket_main.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b12caea6f9a80e16197702c93c2840daadc7e68a
--- /dev/null
+++ b/net/web2socket_proxy/web2socket_main.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2010 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.
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netinet/in.h>
+#include <unistd.h>
+
+#include "web2socket.h"
+
+static void bailout() {
+ fprintf(stderr,
+ "Options:\n"
+ " -p port\tSpecifies port (in 1-65535 range) to listen. Mandatory.\n"
+ " -L\tListens loopback network interface.\n");
+ exit(1);
+}
+
+int main(int ac, char *av[]) {
+ int c;
+ int port = 0;
+ bool loopback = false;
+ if (ac <= 0)
+ bailout();
+ while ((c = getopt(ac, av, "p:L")) != -1) {
+ switch(c) {
+ case 'p': {
+ port = atoi(optarg);
+ break;
+ }
+ case 'L': {
+ loopback = true;
+ break;
+ }
+ default: {
+ bailout();
+ }
+ }
+ }
+ if (port < 1 || port >= 1 << 16)
+ bailout();
+
+ struct sockaddr_in sa;
+ memset(&sa, 0, sizeof(sa));
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+ sa.sin_addr.s_addr = loopback ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
+
+ RunWeb2SocketServer(std::string(),
+ static_cast<sockaddr*>(static_cast<void*>(&sa)),
+ sizeof(sa));
+ return 1;
+}
« no previous file with comments | « net/web2socket_proxy/web2socket_conn.cc ('k') | net/web2socket_proxy/web2socket_serv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698