首页 > 其他 > 详细

incomingConnection qtcpsocket

时间:2021-02-19 17:12:40      阅读:32      评论:0      收藏:0      [点我收藏+]

下面介绍一下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()方法。

incomingConnection qtcpsocket

原文:https://www.cnblogs.com/hshy/p/14415877.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!