Generic socket connect for ip v4 and v6