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. [QTcp] Socket/Server check only first if.
Forum Updated to NodeBB v4.3 + New Features

[QTcp] Socket/Server check only first if.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 411 Views 1 Watching
  • 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.
  • R Offline
    R Offline
    R4leY
    wrote on last edited by
    #1

    Hello i have a little problem because i write program to comunicate with server but server always check only first if. What i must to do ?

    if(socket->readLine() == "x")
    {
    xFunction();
    }
    if(socket->readLine() === "y)
    {
    yFunction():
    }
    1 Reply Last reply
    0
    • hskoglundH Online
      hskoglundH Online
      hskoglund
      wrote on last edited by
      #2

      Hi, the readLine() functions reads ("eats") one line from the server, so try something like this instead:

      QString sLine = socket->readLine()->data();
      
      if(sLine == "x")
      {
      xFunction();
      }
      if(sLine === "y)
      {
      yFunction():
      }
      
      1 Reply Last reply
      3
      • R Offline
        R Offline
        R4leY
        wrote on last edited by
        #3

        thanks it working now :)

        aha_1980A 1 Reply Last reply
        0
        • R R4leY

          thanks it working now :)

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @R4leY so please close this topic as SOLVED. Thanks

          Qt has to stay free or it will die.

          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