此代码段中发生此错误:
void TCPConnectThread::run()
{
m_socket = new QTcpSocket();
m_socket->setSocketDescriptor(m_fd);
m_socket->waitForReadyRead(10000);
QString data = m_socket->readAll();
m_socket->waitForDisconnected();
}
有点深入:
if (::WSAIoctl(socketDescriptor, FIONREAD, &dummy, sizeof(dummy), &nbytes,
sizeof(nbytes), &sizeWritten, 0,0) == SOCKET_ERROR) <-Exception here
{
WS_ERROR_DEBUG(WSAGetLastError());
return -1;
}
深入:
if (::getsockopt(d->socketDescriptor, SOL_SOCKET,
SO_ERROR, (char *) &value, &valueSize) == 0) <-Here
invalid handle
run
退出方法时发生异常。
这是我获得 m_socket 的方法:
m_socket = new QTcpSocket();
m_socket->setSocketDescriptor(m_fd);//m_fd is the socket descriptor of another socket
//from another thread
这是从中m_fd
收集的线程:
void TCPListenerThread::onNewConnection()
{
QTcpSocket *clientSocket = m_tcpServer->nextPendingConnection();
int sockfd = clientSocket->socketDescriptor();
m_connectThread = new TCPConnectThread(sockfd);
m_threadPool->start(m_connectThread);
}
例外:
Most possible exception at 0x76edf9ea in manager_host.exe:
0xC0000008: An invalid handle was specified
我如何以及在哪里可以找到这个无效的句柄?