Add socket error handling to netprot_sock_connected()

Previously it did not check the return value of getsockopt()