OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 parser.SetUsageMessage(usage); | 54 parser.SetUsageMessage(usage); |
55 parser.SetFlag("port", "8888"); | 55 parser.SetFlag("port", "8888"); |
56 parser.SetFlag("help", "false"); | 56 parser.SetFlag("help", "false"); |
57 parser.ProcessFlags(); | 57 parser.ProcessFlags(); |
58 | 58 |
59 if (parser.GetFlag("help") == "true") { | 59 if (parser.GetFlag("help") == "true") { |
60 parser.PrintUsageMessage(); | 60 parser.PrintUsageMessage(); |
61 return 0; | 61 return 0; |
62 } | 62 } |
63 | 63 |
64 int port = strtol((parser.GetFlag("port")).c_str(), NULL, 10); | 64 int port = strtol((parser.GetFlag("port")).c_str(), nullptr, 10); |
65 | 65 |
66 // Abort if the user specifies a port that is outside the allowed | 66 // Abort if the user specifies a port that is outside the allowed |
67 // range [1, 65535]. | 67 // range [1, 65535]. |
68 if ((port < 1) || (port > 65535)) { | 68 if ((port < 1) || (port > 65535)) { |
69 printf("Error: %i is not a valid port.\n", port); | 69 printf("Error: %i is not a valid port.\n", port); |
70 return -1; | 70 return -1; |
71 } | 71 } |
72 | 72 |
73 ListeningSocket listener; | 73 ListeningSocket listener; |
74 if (!listener.Create()) { | 74 if (!listener.Create()) { |
(...skipping 13 matching lines...) Expand all Loading... |
88 while (!quit) { | 88 while (!quit) { |
89 fd_set socket_set; | 89 fd_set socket_set; |
90 FD_ZERO(&socket_set); | 90 FD_ZERO(&socket_set); |
91 if (listener.valid()) | 91 if (listener.valid()) |
92 FD_SET(listener.socket(), &socket_set); | 92 FD_SET(listener.socket(), &socket_set); |
93 | 93 |
94 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) | 94 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) |
95 FD_SET((*i)->socket(), &socket_set); | 95 FD_SET((*i)->socket(), &socket_set); |
96 | 96 |
97 struct timeval timeout = { 10, 0 }; | 97 struct timeval timeout = { 10, 0 }; |
98 if (select(FD_SETSIZE, &socket_set, NULL, NULL, &timeout) == SOCKET_ERROR) { | 98 if (select(FD_SETSIZE, &socket_set, nullptr, nullptr, &timeout) == |
| 99 SOCKET_ERROR) { |
99 printf("select failed\n"); | 100 printf("select failed\n"); |
100 break; | 101 break; |
101 } | 102 } |
102 | 103 |
103 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) { | 104 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) { |
104 DataSocket* s = *i; | 105 DataSocket* s = *i; |
105 bool socket_done = true; | 106 bool socket_done = true; |
106 if (FD_ISSET(s->socket(), &socket_set)) { | 107 if (FD_ISSET(s->socket(), &socket_set)) { |
107 if (s->OnDataAvailable(&socket_done) && s->request_received()) { | 108 if (s->OnDataAvailable(&socket_done) && s->request_received()) { |
108 ChannelMember* member = clients.Lookup(s); | 109 ChannelMember* member = clients.Lookup(s); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 172 } |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) | 176 for (SocketArray::iterator i = sockets.begin(); i != sockets.end(); ++i) |
176 delete (*i); | 177 delete (*i); |
177 sockets.clear(); | 178 sockets.clear(); |
178 | 179 |
179 return 0; | 180 return 0; |
180 } | 181 } |
OLD | NEW |