server.cpp

来自「Android实现远程控制PC源代码」· C++ 代码 · 共 22 行

CPP
22
字号
#include "server.h"
#include "serverthread.h"

Server::Server(MainWindow *m,int p,QHostAddress a)
{
    this->hostAddress=a;
    this->port=p;
    this->mainWindow=m;
    this->clientNum=0;
    this->QTcpServer::listen(hostAddress,quint16(port));
    connect(this,SIGNAL(printText(const char*)),this->mainWindow,SLOT(showText(const char*)));
}

void Server::incomingConnection(int handle)
{
    char ch[]="new connection !";
    emit printText(ch);
    ServerThread *thread=new ServerThread(handle,this,mainWindow,this->clientNum);
    this->clientNum++;
    thread->start();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?