summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/imports/qmlwebsockets/qqmlwebsocketserver.cpp12
-rw-r--r--src/imports/qmlwebsockets/qqmlwebsocketserver.h10
2 files changed, 14 insertions, 8 deletions
diff --git a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp
index acaa5cb..ea666a6 100644
--- a/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp
+++ b/src/imports/qmlwebsockets/qqmlwebsocketserver.cpp
@@ -59,7 +59,9 @@ QT_USE_NAMESPACE
/*!
\qmlproperty int WebSocketServer::port
- The port this server is listening on. By default, a port is chosen automatically.
+ The port this server is listening on. The value must be in the range 0-65535.
+
+ By default, a port is chosen automatically.
*/
/*!
@@ -144,17 +146,21 @@ void QQmlWebSocketServer::setHost(const QString &host)
updateListening();
}
-quint16 QQmlWebSocketServer::port() const
+int QQmlWebSocketServer::port() const
{
return m_port;
}
-void QQmlWebSocketServer::setPort(quint16 port)
+void QQmlWebSocketServer::setPort(int port)
{
if (port == m_port) {
return;
}
+ if (port < 0 || port > 65535) {
+ qWarning() << "QQmlWebSocketServer::setPort: port " << port << " is invalid. It must be in the range 0-65535.";
+ return;
+ }
m_port = port;
emit portChanged(port);
emit urlChanged(url());
diff --git a/src/imports/qmlwebsockets/qqmlwebsocketserver.h b/src/imports/qmlwebsockets/qqmlwebsocketserver.h
index 4759bc4..5d790db 100644
--- a/src/imports/qmlwebsockets/qqmlwebsocketserver.h
+++ b/src/imports/qmlwebsockets/qqmlwebsocketserver.h
@@ -49,7 +49,7 @@ class QQmlWebSocketServer : public QObject, public QQmlParserStatus
Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
Q_PROPERTY(QString host READ host WRITE setHost NOTIFY hostChanged)
- Q_PROPERTY(quint16 port READ port WRITE setPort NOTIFY portChanged)
+ Q_PROPERTY(int port READ port WRITE setPort NOTIFY portChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
Q_PROPERTY(bool listen READ listen WRITE setListen NOTIFY listenChanged)
@@ -67,8 +67,8 @@ public:
QString host() const;
void setHost(const QString &host);
- quint16 port() const;
- void setPort(quint16 port);
+ int port() const;
+ void setPort(int port);
QString name() const;
void setName(const QString &name);
@@ -86,7 +86,7 @@ Q_SIGNALS:
void errorStringChanged(const QString &errorString);
void urlChanged(const QUrl &url);
- void portChanged(quint16 port);
+ void portChanged(int port);
void nameChanged(const QString &name);
void hostChanged(const QString &host);
void listenChanged(bool listen);
@@ -102,7 +102,7 @@ private:
QScopedPointer<QWebSocketServer> m_server;
QString m_host;
QString m_name;
- quint16 m_port;
+ int m_port;
bool m_listen;
bool m_accept;
bool m_componentCompleted;