Alternative to Findout connected devices IP adresses
Do you really want to write it for yourself? Since there are lots of free tools outside, able to tell you this. See Sysinternals TCPview[^] for example, or the built-in windows tool NETSTAT[^].But it is really not complicated at all, check out this...
Turn On Your PC/Computer Programmatically / Automatically –Wake On LAN ( WOL ) Over Internet- Wake On WAN ( WOW)