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

Method setupTcpConnection

app/src/Misc/CLI.cpp:493–513  ·  view source on GitHub ↗

* @brief Configures and connects a TCP socket from a CLI host:port string. */

Source from the content-addressed store, hash-verified

491 * @brief Configures and connects a TCP socket from a CLI host:port string.
492 */
493void CLI::setupTcpConnection(const QString& tcpAddress)
494{
495 const QStringList parts = tcpAddress.split(':');
496 if (parts.size() != 2) {
497 qWarning() << "Invalid TCP address format. Expected: host:port";
498 return;
499 }
500
501 bool ok = false;
502 const quint16 port = parts[1].toUInt(&ok);
503 if (!ok || port == 0) {
504 qWarning() << "Invalid TCP port:" << parts[1];
505 return;
506 }
507
508 IO::ConnectionManager::instance().setBusType(SerialStudio::BusType::Network);
509 IO::ConnectionManager::instance().network()->setTcpSocket();
510 IO::ConnectionManager::instance().network()->setRemoteAddress(parts[0]);
511 IO::ConnectionManager::instance().network()->setTcpPort(port);
512 IO::ConnectionManager::instance().connectDevice();
513}
514
515/**
516 * @brief Applies the optional --udp-remote spec to the active network driver.

Callers

nothing calls this directly

Calls 7

setTcpSocketMethod · 0.80
networkMethod · 0.80
connectDeviceMethod · 0.80
sizeMethod · 0.45
setBusTypeMethod · 0.45
setRemoteAddressMethod · 0.45
setTcpPortMethod · 0.45

Tested by

no test coverage detected