void MainServer::newConnectionFromAdmin() {
QTcpSocket * tcpSocket
= tcpServer.
nextPendingConnection();
ServerThread *serverThread = new ServerThread(tcpSocket->socketDescriptor(),this);
serverThread->start();
connect(serverThread,SIGNAL(finished()),serverThread,SLOT(deleteLater()));
}
void MainServer::newConnectionFromClient()
{
QTcpSocket * tcpSocket
= tspServer.
nextPendingConnection();
ClientThread *clientThread = new ClientThread(tcpSocket->socketDescriptor(),this);
clientThread->start();
connect(clientThread,SIGNAL(finished()),clientThread,SLOT(deleteLater()));
}
ServerThread
::ServerThread(int num,
QObject *parent
){
tcpSocket->setSocketDescriptor(num);
//connections for sockets
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readReq()));
}
/* The running thread's running code */
void ManagerServerThread::run()
{
connect(MainServer *)(this->parent()),SIGNAL(reportToServer(TRep*)),this,SLOT(writeData(TRep*)));
exec();
}
ClientThread
::ClientThread(int num,
QObject *parent
){
tcpSocket.setSocketDescriptor(num);
//connections for sockets
connect(&tcpSocket, SIGNAL(readyRead()), this, SLOT(func()));
connect(&tcpSocket, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer()));
connect(this,SIGNAL(reportToAdmin(TRep*)),(MainServer *)(this->parent()),SIGNAL(reportToServer(TRep*)));
// qDebug() << Q_FUNC_INFO << QThread::currentThreadId();
}
void ClientThread::run()
{
exec();
}
int ClientThread::func()
{
emit reportToAdmin(rep);
{
void MainServer::newConnectionFromAdmin() {
QTcpSocket * tcpSocket = tcpServer.nextPendingConnection();
ServerThread *serverThread = new ServerThread(tcpSocket->socketDescriptor(),this);
serverThread->start();
connect(serverThread,SIGNAL(finished()),serverThread,SLOT(deleteLater()));
}
void MainServer::newConnectionFromClient()
{
QTcpSocket * tcpSocket = tspServer.nextPendingConnection();
ClientThread *clientThread = new ClientThread(tcpSocket->socketDescriptor(),this);
clientThread->start();
connect(clientThread,SIGNAL(finished()),clientThread,SLOT(deleteLater()));
}
ServerThread::ServerThread(int num, QObject *parent)
: QThread(parent), num(num)
{
tcpSocket=new QTcpSocket(this);
tcpSocket->setSocketDescriptor(num);
//connections for sockets
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readReq()));
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
}
/* The running thread's running code */
void ManagerServerThread::run()
{
connect(MainServer *)(this->parent()),SIGNAL(reportToServer(TRep*)),this,SLOT(writeData(TRep*)));
exec();
}
ClientThread::ClientThread(int num, QObject *parent)
: QThread(parent), num(num)
{
tcpSocket.setSocketDescriptor(num);
//connections for sockets
connect(&tcpSocket, SIGNAL(readyRead()), this, SLOT(func()));
connect(&tcpSocket, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer()));
connect(&tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)));
connect(this,SIGNAL(reportToAdmin(TRep*)),(MainServer *)(this->parent()),SIGNAL(reportToServer(TRep*)));
// qDebug() << Q_FUNC_INFO << QThread::currentThreadId();
}
void ClientThread::run()
{
exec();
}
int ClientThread::func()
{
emit reportToAdmin(rep);
{
To copy to clipboard, switch view to plain text mode
Bookmarks