Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTcpServer - Fortune example problem
QtWS25 Last Chance

QTcpServer - Fortune example problem

Scheduled Pinned Locked Moved General and Desktop
27 Posts 4 Posters 10.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.
  • N Offline
    N Offline
    nnn123
    wrote on last edited by
    #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

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nnn123
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          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.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nnn123
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              Do you have "vsaddin":http://developer.qt.nokia.com/wiki/QtVSAddin 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.

              Vote the answer(s) that helped you to solve your issue(s)

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                [quote author="nnn123" date="1312113054"]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?[/quote]
                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) ;-)

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • N Offline
                  N Offline
                  nnn123
                  wrote on last edited by
                  #8

                  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?

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    koahnig
                    wrote on last edited by
                    #9

                    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":http://qt.nokia.com/downloads/windows-cpp-vs2008 . 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.

                    Vote the answer(s) that helped you to solve your issue(s)

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      nnn123
                      wrote on last edited by
                      #10

                      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?

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        koahnig
                        wrote on last edited by
                        #11

                        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.

                        Vote the answer(s) that helped you to solve your issue(s)

                        1 Reply Last reply
                        0
                        • N Offline
                          N Offline
                          nnn123
                          wrote on last edited by
                          #12

                          qmake works. nmake doesn't work.

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            koahnig
                            wrote on last edited by
                            #13

                            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.

                            Vote the answer(s) that helped you to solve your issue(s)

                            1 Reply Last reply
                            0
                            • N Offline
                              N Offline
                              nnn123
                              wrote on last edited by
                              #14

                              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 :-)

                              1 Reply Last reply
                              0
                              • L Offline
                                L Offline
                                loladiro
                                wrote on last edited by
                                #15

                                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.

                                1 Reply Last reply
                                0
                                • K Offline
                                  K Offline
                                  koahnig
                                  wrote on last edited by
                                  #16

                                  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.

                                  Vote the answer(s) that helped you to solve your issue(s)

                                  1 Reply Last reply
                                  0
                                  • N Offline
                                    N Offline
                                    nnn123
                                    wrote on last edited by
                                    #17

                                    So I really don't know what can it be (and I really want to find it out).
                                    I am sure I use the VS2005 command.
                                    The nmake didn't work. When I look in the internet I saw that the files which are missing are VS2008 files. When I tried to create the vcproj from pro file I got an error relating to the Visual studio version. Because of those two reasons I thought that the problem is VS version.
                                    Is there another way to convert pro file to vcproj?

                                    1 Reply Last reply
                                    0
                                    • K Offline
                                      K Offline
                                      koahnig
                                      wrote on last edited by
                                      #18

                                      You should provide the error messages you got.

                                      However, it looks that we are mixing up things.

                                      Here you wrote:
                                      [quote author="nnn123" date="1312177600"]qmake works. nmake doesn't work.[/quote]

                                      This is before any .vproj file. That was your reply on recompilation of the fortune example. This should be a trial with the command prompt started through visual studio. If nmake does not work in the command window opened through visual studio, there is a problem with your visual studio setup.

                                      What is happening when you open the command prompt through visual studio and you simply type nmake?
                                      Please post the messages obtained.

                                      Vote the answer(s) that helped you to solve your issue(s)

                                      1 Reply Last reply
                                      0
                                      • N Offline
                                        N Offline
                                        nnn123
                                        wrote on last edited by
                                        #19

                                        can not open include file stddef.h. no such file or diretory
                                        fatal error U1077 cl return code 0x2
                                        fatal error U1077 make return code 0x2

                                        1 Reply Last reply
                                        0
                                        • K Offline
                                          K Offline
                                          koahnig
                                          wrote on last edited by
                                          #20

                                          It is missing a standard header file. So there is something with your environment wrong.
                                          In your command prompt you can run "set include". There you should find the directory where this file is located. This entry is probably missing.

                                          However, in general I would suggest that you repair or reinstall your visual studio including all service packs. Then you should install Qt and vsaddin again.

                                          The problems you have are not Qt related. It just happened to show up with your trials with the fortune server/client example.

                                          Vote the answer(s) that helped you to solve your issue(s)

                                          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