Qt网络通信Socket建立TCP连接(服务器端)
1、创建监听套接字
tcpServer = new QTcpServer(this);
2、设置监听
tcpServer.listen(QHostAddress::Any,9090);
3、给newConnecttion信号绑定槽函数。等待新连接触发newConnecttion信号。
connect(tcpServer,&QTcpServer::newConnection,slotNewConnection);
4、新连接到来后通过nextPendingConnection取出通信套接字
原创
2020-05-26 18:08:27 ·
1080 阅读 ·
0 评论