Results 1 to 3 of 3

Thread: Implicit share going mad?

  1. #1
    Join Date
    Jun 2011
    Posts
    38
    Thanks
    8
    Thanked 1 Time in 1 Post

    Default Implicit share going mad?

    Hi,

    I had the following code:
    Qt Code:
    1. void NetworkClient::connectToHost( const QString& ip, int port )
    2. {
    3. m_socket->connectToHost(ip, port);
    4. }
    To copy to clipboard, switch view to plain text mode 

    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:
    Qt Code:
    1. void NetworkClient::connectToHost( const QString& ip, int port )
    2. {
    3. QString localIp(ip);
    4. m_socket->connectToHost(localIp, port);
    5. }
    To copy to clipboard, switch view to plain text mode 

    And then it worked!

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

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Implicit share going mad?

    Quote Originally Posted by P@u1 View Post
    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!
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Implicit share going mad?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Classes with Implicit Sharing
    By weaver4 in forum Newbie
    Replies: 5
    Last Post: 15th January 2011, 18:57
  2. Threads and Implicit Sharing
    By stillwaiting in forum Newbie
    Replies: 5
    Last Post: 30th November 2010, 16:46
  3. Implicit sharing and pointers
    By Luc4 in forum Qt Programming
    Replies: 4
    Last Post: 16th June 2010, 10:31
  4. Implicit vs. explicit
    By lni in forum Qt Programming
    Replies: 4
    Last Post: 22nd September 2009, 02:26
  5. QSharedData - implicit sharing
    By gyre in forum Newbie
    Replies: 4
    Last Post: 28th October 2007, 19:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.