incomingConnection qtcpsocket
下面介绍一下incomingConnection
原文解释:
This virtual function is called by QTcpServer
when a new connection is available. The socketDescriptor argument is the
native socket descriptor for the accepted connection.
The base
implementation creates a QTcpSocket, sets the socket descriptor and then
stores the QTcpSocket in an internal list of pending connections.
Finally newConnection() is emitted.
Reimplement this function to alter the server’s behavior when a connection is available.
If this server is using QNetworkProxy then the socketDescriptor may not
be usable with native socket functions, and should only be used with
QTcpSocket::setSocketDescriptor().
Note: If another socket is
created in the reimplementation of this method, it needs to be added to
the Pending Connections mechanism by calling addPendingConnection().
Note: If you want to handle an incoming connection as a new QTcpSocket
object in another thread you have to pass the socketDescriptor to the
other thread and create the QTcpSocket object there and use its
setSocketDescriptor() method.
译文:
当有新的连接可用时,QTcpServer将调用这个虚拟函数。socketDescriptor参数是接受连接的本地套接字描述符。
基本实现创建一个QTcpSocket,设置套接字描述符,然后将QTcpSocket存储在一个挂起连接的内部列表中。最后发出newConnection()。
重新实现此函数,以在连接可用时更改服务器的行为。
如果此服务器使用QNetworkProxy,则socketDescriptor可能不能用于本机套接字函数,只能用于QTcpSocket::setSocketDescriptor()。
注意:如果在此方法的重新实现中创建了另一个套接字,则需要通过调用addPendingConnection()将其添加到挂起连接机制。
注意:如果您想要在另一个线程中处理一个新的QTcpSocket对象,那么您必须将socketDescriptor传递给另一个线程,并在那里创建QTcpSocket对象,然后使用它的setSocketDescriptor()方法。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-02-19 PKCS11
2020-02-19 windows dll
2020-02-19 程序员等级
2020-02-19 书生
2020-02-19 航空661标准者
2020-02-19 听一听世界经典歌曲