Reputation: 4617
I am building a linux Qt5/C++ app which runs on a system with multiple NIC's (multihomed). I need to force my outgoing TCP connection to use a specific NIC/IP. I have tried the following code but netstat confirms that my app is still using the wrong local NIC/IP.
if (m_tcpSocket->bind(localaddress)) qDebug() << "Bind success";
m_tcpSocket->connectToHost(
remoteaddress,
remoteport,
QTcpSocket::ReadWrite);
}
Am I calling this incorrectly? I see "bind success" so I assume the call is right...but I can't explain why its not working
Update: I found this bug report: https://bugreports.qt.io/browse/QTBUG-29732
Is there a workaround? I see setLocalAddress() in QAbstractSocket but I'm not sure it's the same
Upvotes: 3
Views: 732