July 31, 2011

nnn123 nnn123
Lab Rat
13 posts

QTcpServer - Fortune example problem

Page  
1

I all,

I am trying to run the fortune example (the simple client-server example) on windows but it is not working.
In a TCP viewer I see that a connection was established between server and client however the newConnection signal in the server side is not emmited.
In the client side I added the waitForConnected function but it results in timeout error.
I also checked the state and saw that it is HostLookupState.
In addition, I wrote a different server-client application not using QT and it works! (But I need to use QT)
So what am I doing wrong? Can someone solve the mistery?

Thanks

26 replies

July 31, 2011

koahnig koahnig
Mad Scientist
2112 posts

Welcome to the forum.

You have to give some more details on your configuration (what windows, compiler, Qt version). Typically the examples are working, but certainly there is never a guarantee. For this specific eample, it is important to know also from where to where your are trying to make connection.

July 31, 2011

nnn123 nnn123
Lab Rat
13 posts

windows xp, working with visual studio c++ 2005 (created a new QT application), QT version: 4.5.2.
I run the server and client on the same computer. I tried localhost and also tried to write the computer ip

July 31, 2011

koahnig koahnig
Mad Scientist
2112 posts

the actual Qt version is 4.7.3. So you might want to update to the newest version.

Out of curiosity I have just compiled the network example as is. It happened to be Qt 4.7.0. I did following:
Opened command prompt in vs2005

  1. cd c:\qt\4.7.0\examples\network
  2. qmake network.pro
  3. nmake

Started the debug versions of fortuneserver. This provides already your local ip address and supplies also a port. Start fortuneclient. This supplies also local ip address, but you have to input the port. It works.

You might want to do the same with your installation. I have seen that the example code of 4.5.2 is smaller, but I would need to recionfigure my whole setup for comiplation linking 4.5.2. So it could be that it is better to upgrade to recent version.

July 31, 2011

nnn123 nnn123
Lab Rat
13 posts

I see that when I run the example from ‘QT->Examples and Demos’ it works. So I guess the problem is with the visual studio (compilation or project creation). Any idea?

July 31, 2011

koahnig koahnig
Mad Scientist
2112 posts

Do you have vsaddin [developer.qt.nokia.com] installed?
Installing vsaddin wil add an entry “Qt” to your menu in visual studio.
There is an option for opening *.pro files. You can do the same from within visual studio then. This generates a visual studio automatically as I remember. So, it would be basis for you to do some comparison and finding the reasons.

July 31, 2011

koahnig koahnig
Mad Scientist
2112 posts

nnn123 wrote:
I see that when I run the example from ‘QT->Examples and Demos’ it works. So I guess the problem is with the visual studio (compilation or project creation). Any idea?

Did you do the recompilation as I have suggested? Check that you have really recompiled. Otherwise you might see the precomiled version working. This should not be a surprise.
If the recompilation does work, you might have messed something during your trials to setup the project through visual studio.

BTW: It is Qt not QT (QuickTime) ;-)

July 31, 2011

nnn123 nnn123
Lab Rat
13 posts

I have the vsaddin installed however openning the pro file failes with error regarding to visual studio version.
I tried to open visual studio with devenv /useenv but it didn’t work.
I didn’t recompiled with make command since I don’t have the gcc compiler on my computer.
Any other suggestions?

July 31, 2011

koahnig koahnig
Mad Scientist
2112 posts

I thought you want to use visual studio for compilation.

Make sure that you have installed the version of Qt libs. If you have already binaries for visual studio 2005 you can use those. If you do not have the binaries yet, the official download is for 2008 only. Those are not compatible as far as I know. So, you have to download the sources here [qt.nokia.com] . This is the automatic download for the 2008 version, but the second on that page provides the source code. You can compile with vs2005. Follow the guidelines. There is only one stumble stone, which is that the command prompt has to be started from visual studio.
When you have installed that version. You can install and use vsaddin from vs2005.

Alternatively, you may install the whole setup for gcc. Either way is possible. Since you seem to be familar with vs2005, you might want to go that route. However, that is up to you.

Unfortunately, you cannot compile Qt piece by piece and get it to work.

July 31, 2011

nnn123 nnn123
Lab Rat
13 posts

I am sorry I didn’t understand your answer.
I want to compile with visual studio 2005.
I have a proper installation of visual studio, Qt, and vsaddin.
Which installation should I change?

August 1, 2011

koahnig koahnig
Mad Scientist
2112 posts

If you have a proper installation of Qt with visual studio, you should be able to compile the network example as I did. There is no need to have gcc installed. Your previous reply confused me a little then.

Open the command through visual studio tools.
Go to the example\network directory.
Start qmake and nmake afterwards as I have described above. If your installation is ok, you should be able to do so.
With the recompiled version you should also be able to check out the fortune server/client example. If this runs ok, the open question would be what is different to your initial approach. Either you have changed a part of the example program or the settings you have used are a problem.

August 1, 2011

nnn123 nnn123
Lab Rat
13 posts

qmake works. nmake doesn’t work.

August 1, 2011

koahnig koahnig
Mad Scientist
2112 posts

Assuming that you have started the command prompt through vs2005 it should work, when all settings are ok.
Therefore make sure that you did go in vs2005 to “tools” and there is an entry starting the command prompt with the vs environment. This is often forgotten, but it is essential. Otherwise nmake will fail.

August 1, 2011

nnn123 nnn123
Lab Rat
13 posts

I think that I have this problem because I work with visual 2005.
Maybe I need to use something else instead of QTCPSertver.
Thank you very much for your help :-)

August 1, 2011

loladiro loladiro
Lab Rat
596 posts

There should not be a problem!!! I have been able to compiles Qt and all tools and example with every MSVC version since version .NET (2003). Therefore, again make sure you use the VS2005 command promt not just cmd.

August 1, 2011

koahnig koahnig
Mad Scientist
2112 posts

I can also only reiterate it is working fine with visual studio 2005. I have tested the other day the recompilation of the fortune server/client with it.

Page  
1

  ‹‹ QSettings how to save QMap<QString,int> into configuration file      How to catch QSystemTrayIcon quit event ››

You must log in to post a reply. Not a member yet? Register here!