Add error checking.

Some work is still needed (like checking if IP address is reachable).