Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    how to run fortune server/client on two different IPs

    Game Development
    3
    8
    4122
    Loading More Posts
    • 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
      Arpitgarg last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        Do you have a firewall blocking your connection, perhaps?

        1 Reply Last reply Reply Quote 0
        • A
          Arpitgarg last edited by

          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 Reply Quote 0
          • V
            vinb last edited by

            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 Reply Quote 0
            • A
              Arpitgarg last edited by

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

              1 Reply Last reply Reply Quote 0
              • V
                vinb last edited by

                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 Reply Quote 0
                • A
                  Arpitgarg last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • V
                    vinb last edited by

                    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 Reply Quote 0
                    • First post
                      Last post