add -6 option to ws echo_server / cf #148
This commit is contained in:
		| @@ -94,6 +94,7 @@ int main(int argc, char** argv) | ||||
|     bool disableAutomaticReconnection = false; | ||||
|     bool disablePerMessageDeflate = false; | ||||
|     bool greetings = false; | ||||
|     bool ipv6 = false; | ||||
|     bool binaryMode = false; | ||||
|     bool redirect = false; | ||||
|     bool version = false; | ||||
| @@ -171,6 +172,7 @@ int main(int argc, char** argv) | ||||
|     echoServerApp->add_option("--port", port, "Port"); | ||||
|     echoServerApp->add_option("--host", hostname, "Hostname"); | ||||
|     echoServerApp->add_flag("-g", greetings, "Verbose"); | ||||
|     echoServerApp->add_flag("-6", ipv6, "IpV6"); | ||||
|     addTLSOptions(echoServerApp); | ||||
|  | ||||
|     CLI::App* broadcastServerApp = app.add_subcommand("broadcast_server", "Broadcasting server"); | ||||
| @@ -390,7 +392,7 @@ int main(int argc, char** argv) | ||||
|     } | ||||
|     else if (app.got_subcommand("echo_server")) | ||||
|     { | ||||
|         ret = ix::ws_echo_server_main(port, greetings, hostname, tlsOptions); | ||||
|         ret = ix::ws_echo_server_main(port, greetings, hostname, tlsOptions, ipv6); | ||||
|     } | ||||
|     else if (app.got_subcommand("broadcast_server")) | ||||
|     { | ||||
|   | ||||
							
								
								
									
										4
									
								
								ws/ws.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								ws/ws.h
									
									
									
									
									
								
							| @@ -29,7 +29,9 @@ namespace ix | ||||
|     int ws_echo_server_main(int port, | ||||
|                             bool greetings, | ||||
|                             const std::string& hostname, | ||||
|                             const ix::SocketTLSOptions& tlsOptions); | ||||
|                             const ix::SocketTLSOptions& tlsOptions, | ||||
|                             bool ipv6); | ||||
|  | ||||
|     int ws_broadcast_server_main(int port, | ||||
|                                  const std::string& hostname, | ||||
|                                  const ix::SocketTLSOptions& tlsOptions); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ | ||||
|  */ | ||||
|  | ||||
| #include <ixwebsocket/IXWebSocketServer.h> | ||||
| #include <ixwebsocket/IXNetSystem.h> | ||||
| #include <spdlog/spdlog.h> | ||||
| #include <sstream> | ||||
|  | ||||
| @@ -13,11 +14,18 @@ namespace ix | ||||
|     int ws_echo_server_main(int port, | ||||
|                             bool greetings, | ||||
|                             const std::string& hostname, | ||||
|                             const ix::SocketTLSOptions& tlsOptions) | ||||
|                             const ix::SocketTLSOptions& tlsOptions, | ||||
|                             bool ipv6) | ||||
|     { | ||||
|         spdlog::info("Listening on {}:{}", hostname, port); | ||||
|  | ||||
|         ix::WebSocketServer server(port, hostname); | ||||
|         ix::WebSocketServer server(port, | ||||
|                                    hostname, | ||||
|                                    SocketServer::kDefaultTcpBacklog, | ||||
|                                    SocketServer::kDefaultMaxConnections, | ||||
|                                    WebSocketServer::kDefaultHandShakeTimeoutSecs, | ||||
|                                    (ipv6) ? AF_INET6 : AF_INET); | ||||
|  | ||||
|         server.setTLSOptions(tlsOptions); | ||||
|  | ||||
|         server.setOnConnectionCallback( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user