PDA

View Full Version : QTCPSocket



A9am
26th December 2013, 10:36
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

wysota
26th December 2013, 14:31
What do you mean by "connected physically to the system"?

A9am
31st December 2013, 11:36
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?

wysota
31st December 2013, 13:04
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.

anda_skoa
31st December 2013, 14:07
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,
_

A9am
2nd January 2014, 09:50
Hi,

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

anda_skoa
2nd January 2014, 15:49
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,
_

wysota
2nd January 2014, 18:31
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

anda_skoa
3rd January 2014, 00:03
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,
_

A9am
3rd January 2014, 14:14
Thank You... QNetworkConfigurationmanager helped ..