Unexplained infinite loop during TCP connection.
-
I want to do TCP communication. but, Unexplained infinite loop during TCP connection.
I don't have it specifically set to loop.An infinite loop occurs between A and B in the code below
If the IP of the [connectToHost] is used as the loopback address, this problem does not occur.
Is it a code problem or a PC configuration problem?QTcpSocket *m_pTcpSocket; void MyTcp::fnTcpConnect(QString sTcpConnectHostIP, quint16 uiTcpConnectPort, QString sTcpClientIP) { //A connect(m_pTcpSocket, SIGNAL(readyRead()), this, SLOT(fnTcpRecvWifiData())); connect(m_pTcpSocket, &QAbstractSocket::stateChanged, this, &CcuTcp::fnTcpWifiStateChanged ); m_pTcpSocket->setProxy(QNetworkProxy::NoProxy); m_pTcpSocket->bind( QHostAddress( sTcpClientIP ), QAbstractSocket::DefaultForPlatform); //B m_pTcpSocket->connectToHost( sTcpConnectHostIP, uiTcpConnectPort ); }
<Environment>
Qt: 5.15.2 MinGW 64bit
OS: Windows10(Virtual machine on Linux) -
@w-tkm said in Unexplained infinite loop during TCP connection.:
An infinite loop occurs between A and B in the code below
What exactly do you mean by "infinite loop"? What is looping?
-
-
@jsulm
If the IP address of connectToHost is set to 127.0.0.1, it will not be called after that.
Also, if I add a subnet with the desired IP address to the virtual NIC, it will not be called again.
(If I want to connect to 192.168.50.1, add 192.168.50.0)Apparently there was a problem with the operation in the virtual environment.
I've never been able to figure out what caused it, but...