PDA

View Full Version : Implicit share going mad?



P@u1
22nd June 2011, 16:37
Hi,

I had the following code:


void NetworkClient::connectToHost( const QString& ip, int port )
{
m_socket->connectToHost(ip, port);
}


and the connect never worked, although i checked the ip and the port with the debugger.

Then I changed it to the following without changing anything else:


void NetworkClient::connectToHost( const QString& ip, int port )
{
QString localIp(ip);
m_socket->connectToHost(localIp, port);
}


And then it worked!

I think it has something to do with implicit sharing, but I don't understand, why this happens!
Please help :-)

mcosta
22nd June 2011, 17:37
and the connect never worked, although i checked the ip and the port with the debugger.


Hi,

what do you mean with "never worked"?

Have you tried to catch QAbstractSocket::stateChanged and QAbstractSocket::error signals?

When you used old code, have you used some LAN sniffer to see the TCP traffic?

It's very strange!

wysota
22nd June 2011, 17:57
So... what's implicit sharing have to do with this? In your second snippet "localIp" still shares data with "ip" and the potential copy that goes into connectToHost.