From 6652af1932ff6ed9da11dd4c41cfba97d87f2747 Mon Sep 17 00:00:00 2001 From: Akira Ohgaki <akiraohgaki@gmail.com> Date: Mon, 1 May 2017 14:59:21 +0900 Subject: [PATCH] 49152 as default port --- app/src/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main.cpp b/app/src/main.cpp index 24493f6..076ae3f 100644 --- a/app/src/main.cpp +++ b/app/src/main.cpp @@ -5,6 +5,7 @@ #include <QCommandLineParser> #include <QCommandLineOption> #include <QCoreApplication> +#include <QDebug> #include "handlers/confighandler.h" //#include "handlers/systemhandler.h" @@ -36,17 +37,24 @@ int main(int argc, char *argv[]) clParser.setApplicationDescription(appConfigApplication["description"].toString()); clParser.addHelpOption(); clParser.addVersionOption(); - QCommandLineOption clPortOption(QStringList() << "p" << "port", "Port for websocket server [default: 443].", "port", "443"); - clParser.addOption(clPortOption); + + // Port 49152-61000 will available as ephemeral port + // https://en.wikipedia.org/wiki/Ephemeral_port + QCommandLineOption clOptionPort(QStringList() << "p" << "port", "Port for websocket server [default: 49152].", "port", "49152"); + clParser.addOption(clOptionPort); + clParser.process(app); - int port = clParser.value(clPortOption).toInt(); + int port = clParser.value(clOptionPort).toInt(); // Setup websocket server WebSocketServer *webSocketServer = new WebSocketServer(appConfigApplication["id"].toString(), port, &app); if (!webSocketServer->start()) { - qFatal(webSocketServer->errorString()); + qCritical() << "Failed to start websocket server:" << webSocketServer->errorString(); + return 1; } + qDebug() << "Websocket server started at:" <<webSocketServer->serverUrl().toString(); + return app.exec(); } -- GitLab