Results 1 to 10 of 10

Thread: QTCPSocket

  1. #1
    Join Date
    Oct 2011
    Posts
    48
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default QTCPSocket

    Hi,

    I want to connect to a tcp server using a QTcpSocket class. connectToHost() is working fine . But I want to know whether the server is connected physically to the system. Like plug and play. If i connect the device of certain IP, I should get notification as the server is connected. How can I achieve this??


    Please help Thanks

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

    Default Re: QTCPSocket

    What do you mean by "connected physically to the system"?
    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.


  3. #3
    Join Date
    Oct 2011
    Posts
    48
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default Re: QTCPSocket

    I mean the ethernet cable connected and the host is reachable. I want to know whenever the host is reachable without calling any APIs. If the host is reachable, i should get some notification or should autoconnect to the host. Any way to do this?

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

    Default Re: QTCPSocket

    There is no way of knowing that. What you mean by "plug and play" works only if you pull the plug from the current machine and system daemons revoke a network interface.
    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.


  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QTCPSocket

    Quote Originally Posted by A9am View Post
    If the host is reachable, i should get some notification or should autoconnect to the host. Any way to do this?
    Call QTcpSocket::connectToHost()
    if the host is reachable you will get a notification (the socket emits the connected() signal) and you will also automatically be connected to the host.

    Cheers,
    _

  6. #6
    Join Date
    Oct 2011
    Posts
    48
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default Re: QTCPSocket

    Hi,

    As registerDeviceNotification for usb device plug and play. If i connect ethernet cable, I should get a notification . Is this possible?

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QTCPSocket

    That could be possible, your operating system APIs might provide such low level events.

    In most systems the applications only need to know if the network configuration changes, i.e. they are not interested in the network cable being plugged in but in a network interface coming up on that ethernet connection.
    That should be doable through QNetworkConfigurationManager

    Cheers,
    _

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QTCPSocket

    Quote Originally Posted by anda_skoa View Post
    That could be possible, your operating system APIs might provide such low level events.

    In most systems the applications only need to know if the network configuration changes, i.e. they are not interested in the network cable being plugged in but in a network interface coming up on that ethernet connection.
    That should be doable through QNetworkConfigurationManager
    Which of course won't help with anything if you pull the plug in the router your machine is connected to
    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.


  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: QTCPSocket

    Quote Originally Posted by wysota View Post
    Which of course won't help with anything if you pull the plug in the router your machine is connected to
    Absolutely.
    It seems A9am's goals are shifting around.

    Obviously detecting local network connectivity is only the pre-requisite for testing the route by sending packets.

    Cheers,
    _

  10. #10
    Join Date
    Oct 2011
    Posts
    48
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    6

    Default Re: QTCPSocket

    Thank You... QNetworkConfigurationmanager helped ..

Similar Threads

  1. QTcpSocket Help
    By minotaurds in forum Qt Programming
    Replies: 0
    Last Post: 20th October 2011, 12:18
  2. QTcpSocket
    By Fallen_ in forum Qt Programming
    Replies: 5
    Last Post: 26th August 2010, 06:32
  3. Need Help with QTcpSocket
    By jknotzke in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2009, 14:55
  4. QTcpSocket
    By pdoria in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2009, 18:52
  5. QT4.2.2 and QTcpSocket
    By Nyphel in forum Qt Programming
    Replies: 13
    Last Post: 11th March 2007, 12:30

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.