Hi,
In order to test any type of port, you will need to have some device connected and test the communication. If you are trying to create a program that only allows the application to proceed if it cannot verify that the port is communicating, I recommend using a basic command (such as a device identification query). If this command returns an error or times out, then the port communication is not set up.
What device are you trying to test the ethernet and USB ports on? What devices will you be connecting to each of these ports? General commands and coding applications are device specific, so the more information you can give me the better.
I hope this gives you a general idea of where to begin, but if not, do not hesitate to respond with more information and we can try to work through everything.
Regards,
Lauren L.
Applications Engineering
National Instruments