Dear Experts,
I am programming a software for a hardware interfaced using either the comport or the ethernet.

I am now specifying in my software whether the harware device has to be connected using comport or the ethernet and then i am clicking on connect button to connect to the machine. And if the software finds that the machine is not connected with the specified connection then it gives an error message.

But what i want to do is.... When i click on Connect Machine button, then my software should automatically search for, which connection the machine is being connected and then connect using that perticular connection. How can i do this?

Please help with this query.....