m_ptcpServer = new QTcpServer(this); if (!m_ptcpServer->listen(QHostAddress::Any,nPorta)) { QMessageBox::critical(0, "server error", "Unable to start the server:"+m_ptcpServer->errorString()); m_ptcpServer->close(); return; } connect(m_ptcpServer, SIGNAL(newConnection()), this, SLOT(slotNewConnection()));
void slotNewConnection() { pClientSocket =m_ptcpServer->nextPendingConnection(); connect(pClientSocket,SIGNAL(disconnected()), pClientSocket,SLOT(deleteLater())); connect(pClientSocket,SIGNAL(readyRead()), this,SLOT(slotReadClient())); }
void toclient(){ QString ss=1млн.байт; if (ss.size()>0) { QTextStream out(pClientSocket); out<<ss;}}