Modified to use alarm to break out of blocking connect call when port is closed.