qt客户端连接服务器不响应,QTcpServer或QTcpClient(在服务器端)知道,连接的客户端现在断开连接...

你内心incomingConnection(int)创建的插座有一个disconnected()信号。使用QSignalMapper来确定哪个套接字已断开连接并更新您的表视图。快速和肮脏的代码,可能有帮助,肯定是语法错误:

TcpServer::TcpServer(QWidget *parent) :

QDialog(parent),

ui(new Ui::TcpServer)

{

ui->setupUi(this);

m_coisSerSo = new CoisServerSocket(this);

count = 0;

// The mapper forwards the signal from the client socket,

// adding the socket itself as an argument.

this->mapper = new QSignalMapper(this);

connect(this->mapper, SIGNAL(mapped(QObject*)),

this, SLOT(clientDisconnected(QObject*)));

connect(m_coisSerSo,SIGNAL(newConnection()),this, SLOT(updateConnectionTable()));

}

void CoisServerSocket::incomingConnection(int socketId)

{

socketClient = new CoisClientSocket(this);

socketClient->setSocketDescriptor(socketId);

/

你可能感兴趣的:(qt客户端连接服务器不响应)