how to run fortune server/client on two different IPs
-
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 -
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 -
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
-
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