Bug Description:
When you have more than one network adater on your compter, this part of the code is supposed to find one that is connecting and working fine and obtain its ip address for handshaking request.
However, it failed to do so when the first network adapter is not connected. Thus GetAdapterState returns false and we stopped trying on the other adapters.
Fix:
Try each adapter, if it is not working, we try the next one. Either we find one and we move onto the following process or we find none and quit.