本文整理汇总了C++中TcpSocket::port方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpSocket::port方法的具体用法?C++ TcpSocket::port怎么用?C++ TcpSocket::port使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpSocket
的用法示例。
在下文中一共展示了TcpSocket::port方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
ConnectionPointer<Connection> ConnectionManager2::getConnWithConfig(quint8 type, const QHash<QString, QVariant> &cfg)
{
this->refresh();
#ifdef HAVE_LIBYB
// We want to receive first USB enumeration events,
// so that connections created here can be opened
QApplication::processEvents();
#endif
Connection *enumCon = NULL;
for(int i = 0; i < m_conns.size(); ++i)
{
if(m_conns[i]->getType() != type)
continue;
switch(type)
{
case CONNECTION_SERIAL_PORT:
{
SerialPort *sp = (SerialPort*)m_conns[i];
if(sp->deviceName() == cfg["device_name"])
{
if(!sp->removable())
enumCon = sp;
else if(sp->baudRate() == cfg["baud_rate"])
return ConnectionPointer<Connection>::fromPtr(sp);
}
break;
}
case CONNECTION_TCP_SOCKET:
{
TcpSocket *socket = (TcpSocket*)m_conns[i];
if(socket->host() == cfg["host"] && socket->port() == cfg["port"])
return ConnectionPointer<Connection>::fromPtr(socket);
break;
}
case CONNECTION_UDP_SOCKET:
{
UdpSocket *socket = (UdpSocket*)m_conns[i];
if (socket->name() == cfg["name"] &&
socket->host() == cfg["host"] && socket->port() == cfg["port"])
return ConnectionPointer<Connection>::fromPtr(socket);
break;
}
case CONNECTION_PROXY_TUNNEL:
{
ProxyTunnel *tunnel = (ProxyTunnel*)m_conns[i];
if(tunnel->name() == cfg["name"])
return ConnectionPointer<Connection>::fromPtr(tunnel);
break;
}
case CONNECTION_SHUPITO_TUNNEL:
{
QHash<QString, QVariant> c = cfg.value("companions").toHash();
QHash<QString, QVariant>::iterator itr = c.find(ShupitoTunnel::getCompanionName());
if(itr == c.end())
return ConnectionPointer<Connection>();
qint64 id = itr.value().toLongLong();
if(id != 0 && id == m_conns[i]->getCompanionId(ShupitoTunnel::getCompanionName()))
return ConnectionPointer<Connection>::fromPtr((ShupitoTunnel*)m_conns[i]);
break;
}
case CONNECTION_SHUPITO_SPI_TUNNEL:
{
QHash<QString, QVariant> c = cfg.value("companions").toHash();
QHash<QString, QVariant>::iterator itr = c.find(ShupitoSpiTunnelConn::getCompanionName());
if(itr == c.end())
return ConnectionPointer<Connection>();
qint64 id = itr.value().toLongLong();
if(id != 0 && id == m_conns[i]->getCompanionId(ShupitoSpiTunnelConn::getCompanionName()))
return ConnectionPointer<Connection>::fromPtr((ShupitoSpiTunnelConn*)m_conns[i]);
break;
}
#ifdef HAVE_LIBYB
case CONNECTION_USB_ACM2:
{
UsbAcmConnection2 *usb = (UsbAcmConnection2*)m_conns[i];
if (usb->vid() == cfg.value("vid", 0).toInt() &&
usb->pid() == cfg.value("pid", 0).toInt() &&
usb->serialNumber() == cfg.value("serial_number").toString() &&
usb->intfName() == cfg.value("intf_name").toString() &&
usb->baudRate() == cfg.value("baud_rate", 115200).toInt() &&
usb->stopBits() == cfg.value("stop_bits", 0).toInt() &&
usb->parity() == (UsbAcmConnection2::parity_t)cfg.value("parity", 0).toInt() &&
usb->dataBits() == cfg.value("data_bits", 8).toInt())
{
usb->applyConfig(cfg);
return ConnectionPointer<Connection>::fromPtr(usb);
}
break;
}
case CONNECTION_SHUPITO23:
{
UsbShupito23Connection *usb = (UsbShupito23Connection*)m_conns[i];
if (usb->vid() == cfg.value("vid", 0).toInt() &&
usb->pid() == cfg.value("pid", 0).toInt() &&
usb->serialNumber() == cfg.value("serial_number").toString() &&
//.........这里部分代码省略.........
示例2: updateDetailsUi
void ChooseConnectionDlg::updateDetailsUi(Connection * conn)
{
updateEditText(ui->connectionNameEdit, conn->name());
ui->actionRemoveConnection->setEnabled(conn->removable());
ui->actionConnect->setEnabled(conn->state() == st_disconnected);
ui->actionDisconnect->setEnabled(conn->state() == st_connected || conn->state() == st_connect_pending || conn->state() == st_disconnecting);
ui->programmerSelection->setVisible(false);
ui->persistNameButton->setVisible(conn->isNamePersistable());
ui->persistNameButton->setEnabled(!conn->hasDefaultName());
switch (conn->getType())
{
case CONNECTION_SERIAL_PORT:
{
SerialPort * sp = static_cast<SerialPort *>(conn);
ui->settingsStack->setCurrentWidget(ui->serialPortPage);
updateEditText(ui->spBaudRateEdit->lineEdit(), QString::number((int)sp->baudRate()));
updateEditText(ui->spDeviceNameEdit, sp->deviceName());
updateComboIndex(ui->spParity, (int)sp->parity());
updateComboIndex(ui->spStopBits, (int)sp->stopBits());
updateComboText(ui->spDataBits, QString::number(sp->dataBits()));
ui->spDeviceNameEdit->setEnabled(sp->devNameEditable());
ui->programmerSelection->setVisible(m_allowedConns & pct_port_programmable);
setActiveProgBtn(sp->programmerType());
}
break;
case CONNECTION_TCP_SOCKET:
{
TcpSocket * tc = static_cast<TcpSocket *>(conn);
ui->settingsStack->setCurrentWidget(ui->tcpClientPage);
updateEditText(ui->tcHostEdit, tc->host());
ui->tcPortEdit->setValue(tc->port());
ui->programmerSelection->setVisible(m_allowedConns & pct_port_programmable);
setActiveProgBtn(tc->programmerType());
}
break;
case CONNECTION_USB_ACM2:
{
UsbAcmConnection2 * c = static_cast<UsbAcmConnection2 *>(conn);
ui->settingsStack->setCurrentWidget(ui->usbAcmConnPage);
updateComboText(ui->usbBaudRateEdit, QString::number((int)c->baudRate()));
updateComboIndex(ui->usbParityCombo, (int)c->parity());
updateComboIndex(ui->usbStopBitsCombo, (int)c->stopBits());
updateComboText(ui->usbDataBitsCombo, QString::number(c->dataBits()));
updateEditText(ui->usbVidEdit, QString("%1").arg(c->vid(), 4, 16, QChar('0')));
updateEditText(ui->usbPidEdit, QString("%1").arg(c->pid(), 4, 16, QChar('0')));
updateEditText(ui->usbAcmSnEdit, c->serialNumber());
updateEditText(ui->usbIntfNameEdit, c->intfName());
bool editable = !c->enumerated() && (c->state() == st_disconnected || c->state() == st_missing);
ui->usbVidEdit->setEnabled(editable);
ui->usbPidEdit->setEnabled(editable);
ui->usbAcmSnEdit->setEnabled(editable);
ui->usbIntfNameEdit->setEnabled(editable);
ui->programmerSelection->setVisible(m_allowedConns & pct_port_programmable);
setActiveProgBtn(c->programmerType());
}
break;
case CONNECTION_USB_SHUPITO:
case CONNECTION_SHUPITO23:
{
ShupitoConnection * c = static_cast<ShupitoConnection *>(conn);
ShupitoFirmwareDetails fd;
if (c->getFirmwareDetails(fd))
{
ui->shupito23HardwareLabel->setText(QString("%1.%2").arg(fd.hw_major).arg(fd.hw_minor));
ui->shupito23FirmwareLabel->setText(fd.firmwareFilename());
ui->settingsStack->setCurrentWidget(ui->shupito23Page);
}
else
{
ui->settingsStack->setCurrentWidget(ui->noSettingsPage);
}
}
break;
case CONNECTION_SHUPITO_TUNNEL:
{
ShupitoTunnel * st = static_cast<ShupitoTunnel *>(conn);
ui->programmerSelection->setVisible(m_allowedConns & pct_port_programmable);
setActiveProgBtn(st->programmerType());
ui->settingsStack->setCurrentWidget(ui->noSettingsPage);
}
break;
default:
{
ui->settingsStack->setCurrentWidget(ui->noSettingsPage);
}
break;
}
}