Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. how to run fortune server/client on two different IPs
QtWS25 Last Chance

how to run fortune server/client on two different IPs

Scheduled Pinned Locked Moved Game Development
8 Posts 3 Posters 4.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arpitgarg
    wrote on last edited by
    #1

    Hi,
    I am a student, I want to run fortune examples on two computer connected over a network one as a server other as a client. I tried doing it and changed the code for finding IP address to

    @QString ipAddress="10.0.0.132";
    QHostAddress(QHostAddress("10.0.0.132") );@

    and network configration manager code to
    @
    QNetworkConfigurationManager manager;
    if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
    // Get saved network configuration
    QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
    settings.beginGroup(QLatin1String("QtNetwork"));
    const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
    settings.endGroup();

        // If the saved network configuration is not currently discovered use the system default
        QNetworkConfiguration config = manager.configurationFromIdentifier(id);
        if ((config.state() & QNetworkConfiguration::InternetAccessPoint) !=
            QNetworkConfiguration::InternetAccessPoint) {
            config = manager.defaultConfiguration();
        }
    
        networkSession = new QNetworkSession(config, this);
        connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));
    

    @
    Rest of the code is same. but it isn't working, pls help me in finding the error or how to proceed .

    Thanks
    Arpit

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Do you have a firewall blocking your connection, perhaps?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Arpitgarg
        wrote on last edited by
        #3

        No , i have disabled it.
        I am a beginner, can u tell me is this code correct. Actually i have to make a project in which i take some user input and send it to another computer using a TCP connection.I am trying my hands on the fortune sever/client example first to understand. I am able to accept user input(joystick ).Can u pls guide me on networking part.I am finding documentation difficult to understand.

        Also i got some doubts about network configration manager part. can u pls explain me how is this using all these strings(Trollrech, DefaultNetworkConfiguration) to get reqd configrations.

        @ QNetworkConfigurationManager manager;
        if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
        // Get saved network configuration
        QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
        settings.beginGroup(QLatin1String("QtNetwork"));
        const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
        settings.endGroup();

            // If the saved network configuration is not currently discovered use the system default
            QNetworkConfiguration config = manager.configurationFromIdentifier(id);
            if ((config.state() & QNetworkConfiguration::Discovered) !=
                QNetworkConfiguration::Discovered) {
                config = manager.defaultConfiguration();
            }
        

        @
        Thanks

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #4

          i tried the fortune-server/client on 2 computers and it worked as expected.
          Did you check your firewall as Andre suggested?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Arpitgarg
            wrote on last edited by
            #5

            Thanks,my firewall was blocking it.
            now could u please explain me network configration manager part.

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vinb
              wrote on last edited by
              #6

              What do you not understand about the documentation then?

              Edit:
              take a look at the next link, its is a good explanation.

              http://smallqtcore.googlecode.com/hg/smallqtcore/src/bearer/qnetworkconfiguration.cpp

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Arpitgarg
                wrote on last edited by
                #7

                documentation does not explain how is it using all these strings(Trollrech, DefaultNetworkConfiguration) to get reqd configrations.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vinb
                  wrote on last edited by
                  #8

                  change one string in only the client or server side and see what happens

                  edit:
                  http://doc.qt.nokia.com/4.7/qsettings.html.
                  Its all in here

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved