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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/web2socket_proxy/web2socket_conn.cc ('k') | net/web2socket_proxy/web2socket_serv.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8
9 #include <netinet/in.h>
10 #include <unistd.h>
11
12 #include "web2socket.h"
13
14 static void bailout() {
15 fprintf(stderr,
16 "Options:\n"
17 " -p port\tSpecifies port (in 1-65535 range) to listen. Mandatory.\n"
18 " -L\tListens loopback network interface.\n");
19 exit(1);
20 }
21
22 int main(int ac, char *av[]) {
23 int c;
24 int port = 0;
25 bool loopback = false;
26 if (ac <= 0)
27 bailout();
28 while ((c = getopt(ac, av, "p:L")) != -1) {
29 switch(c) {
30 case 'p': {
31 port = atoi(optarg);
32 break;
33 }
34 case 'L': {
35 loopback = true;
36 break;
37 }
38 default: {
39 bailout();
40 }
41 }
42 }
43 if (port < 1 || port >= 1 << 16)
44 bailout();
45
46 struct sockaddr_in sa;
47 memset(&sa, 0, sizeof(sa));
48 sa.sin_family = AF_INET;
49 sa.sin_port = htons(port);
50 sa.sin_addr.s_addr = loopback ? htonl(INADDR_LOOPBACK) : htonl(INADDR_ANY);
51
52 RunWeb2SocketServer(std::string(),
53 static_cast<sockaddr*>(static_cast<void*>(&sa)),
54 sizeof(sa));
55 return 1;
56 }
OLDNEW
« 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