MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setTcpPort

Method setTcpPort

app/src/API/Handlers/NetworkHandler.cpp:139–158  ·  view source on GitHub ↗

* @brief Set TCP port */

Source from the content-addressed store, hash-verified

137 * @brief Set TCP port
138 */
139API::CommandResponse API::Handlers::NetworkHandler::setTcpPort(const QString& id,
140 const QJsonObject& params)
141{
142 if (!params.contains(QStringLiteral("port"))) {
143 return CommandResponse::makeError(
144 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: port"));
145 }
146
147 const int port = params.value(QStringLiteral("port")).toInt();
148 if (port < 1 || port > 65535) {
149 return CommandResponse::makeError(
150 id, ErrorCode::InvalidParam, QStringLiteral("Port must be between 1 and 65535"));
151 }
152
153 IO::ConnectionManager::instance().network()->setTcpPort(static_cast<quint16>(port));
154
155 QJsonObject result;
156 result[QStringLiteral("tcpPort")] = port;
157 return CommandResponse::makeSuccess(id, result);
158}
159
160/**
161 * @brief Set UDP local port

Callers

nothing calls this directly

Calls 3

networkMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected