Results 1 to 2 of 2

Thread: remote port of a socket that hasn't connected yet

  1. #1
    Join Date
    Nov 2008
    Posts
    38
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default remote port of a socket that hasn't connected yet

    Hi there.

    I have created a QTcpSocket and called connectToHost on a given address and port. Later I respond to the stateChanged signal before it's in the ConnectedState state and need to know the address and port the socket is trying to connect to. Unfortunately while peerName remembers who connectToHost was referring to, peerPort returns zero until after the connection has been made.

    Apart from being irritatingly inconsistent, is there another way to fetch the port as passed to connectToHost? Storing a copy elsewhere breaks my encapsulation

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: remote port of a socket that hasn't connected yet

    Well... if the socket doesn't know what it is connecting to, it is hard for it to return a real value. If you are the active (connecting) socket, you should know where you connect to or you can store this information in the socket object if you want.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.