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
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.
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
- cd c:\qt\4.7.0\examples\network
- qmake network.pro
- 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.
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.
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) ;-)
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.
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.
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.
You must log in to post a reply. Not a member yet? Register here!



