Results 1 to 2 of 2

Thread: Use specific port on a client QTcpSocket

  1. #1
    Join Date
    Mar 2014
    Thanked 1 Time in 1 Post
    Qt products

    Default Use specific port on a client QTcpSocket

    I'm trying to set it up so that when a client connects to a server, the client uses a specified port. Right now the client uses a random port. It looked like binding would work, but it didn't change anything it still used a random port. Is there a way to force the client to use a specific port? I'm using Windows 10, Visual Studio 2013, and Qt 5.4.1 64-bit. If you need something like a sample of the code, let me know. It's kind of a pain. My work computer doesn't have internet, so I have to burn it to a CD, carry it over, and transfer to the computer that has internet. But if it will help, I'm willing to do it.

  2. #2
    Join Date
    Jan 2006
    Warsaw, Poland
    Thanked 5,005 Times in 4,784 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    Wiki edits

    Default Re: Use specific port on a client QTcpSocket

    Why do you need the client to use a specified port? This is not usually desired as the port might be in use by some other software. You should be able to use bind() to do this unless your OS prevents you from binding to a specific port (e.g. ports lower than 1024 are usually reserved).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.

Similar Threads

  1. Client Server connection through specific port
    By Cerberus in forum Qt Programming
    Replies: 4
    Last Post: 22nd October 2015, 17:10
  2. Replies: 0
    Last Post: 22nd June 2015, 02:46
  3. Binding QTcpSocket to a specific network interface
    By vkincaid in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2010, 21:28
  4. Replies: 1
    Last Post: 21st March 2010, 21:14
  5. client/server without port
    By evgenM in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2006, 12:10


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.