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. Problem with DNS lookup
Forum Updated to NodeBB v4.3 + New Features

Problem with DNS lookup

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 869 Views 2 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.
  • M Offline
    M Offline
    mentalwasteland
    wrote on last edited by
    #1

    I have a set of (non-Qt) applications written in C and C++. I use standard TCP sockets -- server and clients, to send and receive the data. I have simple TcpClient and TcpServer classes so I'm not re-writing code. Everything works fine. But I was then asked to add the client to a Qt appliction. Now, my TCP client fails to initialize in Qt (it compiles without error). In particular, the call to gethostbyname( "localhost") returns a null pointer. Looking through the documentation and examples, i can't find any references on how to resolve a host name outside of the QTcpSocket stuff, and I'd rather not have to recreate my socket. Any suggestions on how to resolve the host name in the Qt environment equivalent to gethostbyname()? BTW, I tested with "localhost" and still got a null pointer. If I am required (grumble) to us QTcpSocket, can anyone point me to a good example of creating a non-blocking Qt client that connects to a non-QT TCP server?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What error do you get ?

      In any case, you don't need QTcpSocket, QHostInfo is there for that.

      Qt's network stack is non blocking.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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