summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-01-10 15:54:08 +0100
committerGeorge Peter Banyard <girgias@php.net>2020-04-21 20:41:26 +0200
commit7ff8eaa5451275a5ce97b29381fc08412e6489d7 (patch)
treeab20dad68a6009d8bff7872bec5abbfd5fae50f7
parent2aa661887f2f313d5dbac04f78f07ab59c06d6d8 (diff)
downloadphp-git-7ff8eaa5451275a5ce97b29381fc08412e6489d7.tar.gz
Promote warnings to Errors in sockets's extension.
-rw-r--r--ext/sockets/multicast.c22
-rw-r--r--ext/sockets/sendrecvmsg.c33
-rw-r--r--ext/sockets/sockets.c164
-rw-r--r--ext/sockets/tests/mcast_ipv4_send_error.phpt26
-rw-r--r--ext/sockets/tests/socket_connect_params.phpt13
-rw-r--r--ext/sockets/tests/socket_create_pair-wrongparams-win32.phpt22
-rw-r--r--ext/sockets/tests/socket_create_pair-wrongparams.phpt24
-rw-r--r--ext/sockets/tests/socket_export_stream-4-win.phpt7
-rw-r--r--ext/sockets/tests/socket_export_stream-4.phpt2
-rw-r--r--ext/sockets/tests/socket_import_stream-4-win.phpt7
-rw-r--r--ext/sockets/tests/socket_import_stream-4.phpt2
-rw-r--r--ext/sockets/tests/socket_send_params.phpt10
-rw-r--r--ext/sockets/tests/socket_sendto_params.phpt10
-rw-r--r--ext/sockets/tests/socket_set_option_error_socket_option.phpt2
-rw-r--r--ext/sockets/tests/socket_set_option_rcvtimeo.phpt10
-rw-r--r--ext/sockets/tests/socket_set_option_seolinger.phpt20
-rw-r--r--ext/sockets/tests/socket_set_option_sndtimeo.phpt10
-rw-r--r--ext/sockets/tests/socket_shutdown-win32.phpt4
-rw-r--r--ext/sockets/tests/socket_shutdown.phpt4
19 files changed, 205 insertions, 187 deletions
diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c
index 663d644070..d7f435cd85 100644
--- a/ext/sockets/multicast.c
+++ b/ext/sockets/multicast.c
@@ -87,14 +87,11 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out)
if (Z_TYPE_P(val) == IS_LONG) {
if (Z_LVAL_P(val) < 0 || (zend_ulong)Z_LVAL_P(val) > UINT_MAX) {
- php_error_docref(NULL, E_WARNING,
- "The interface index cannot be negative or larger than %u;"
- " given " ZEND_LONG_FMT, UINT_MAX, Z_LVAL_P(val));
- ret = FAILURE;
- } else {
- *out = Z_LVAL_P(val);
- ret = SUCCESS;
+ zend_value_error("Index must be between 0 and %u", UINT_MAX);
+ return FAILURE;
}
+ *out = Z_LVAL_P(val);
+ ret = SUCCESS;
} else {
zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(val, &tmp_str);
@@ -127,7 +124,7 @@ static int php_get_address_from_array(const HashTable *ht, const char *key,
zend_string *str, *tmp_str;
if ((val = zend_hash_str_find(ht, key, strlen(key))) == NULL) {
- php_error_docref(NULL, E_WARNING, "No key \"%s\" passed in optval", key);
+ zend_value_error("No key \"%s\" passed in optval", key);
return FAILURE;
}
str = zval_get_tmp_string(val, &tmp_str);
@@ -282,8 +279,7 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
case IP_MULTICAST_TTL:
convert_to_long_ex(arg4);
if (Z_LVAL_P(arg4) < 0L || Z_LVAL_P(arg4) > 255L) {
- php_error_docref(NULL, E_WARNING,
- "Expected a value between 0 and 255");
+ zend_argument_value_error(4, "must be between 0 and 255");
return FAILURE;
}
ipv4_mcast_ttl_lback = (unsigned char) Z_LVAL_P(arg4);
@@ -347,8 +343,7 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
case IPV6_MULTICAST_HOPS:
convert_to_long_ex(arg4);
if (Z_LVAL_P(arg4) < -1L || Z_LVAL_P(arg4) > 255L) {
- php_error_docref(NULL, E_WARNING,
- "Expected a value between -1 and 255");
+ zend_argument_value_error(4, "must be between -1 and 255");
return FAILURE;
}
ov = (int) Z_LVAL_P(arg4);
@@ -496,8 +491,7 @@ static int _php_mcast_join_leave(
}
#endif
else {
- php_error_docref(NULL, E_WARNING,
- "Option %s is inapplicable to this socket type",
+ zend_value_error("Option %s is inapplicable to this socket type",
join ? "MCAST_JOIN_GROUP" : "MCAST_LEAVE_GROUP");
return -2;
}
diff --git a/ext/sockets/sendrecvmsg.c b/ext/sockets/sendrecvmsg.c
index 211495f327..6e145f57d9 100644
--- a/ext/sockets/sendrecvmsg.c
+++ b/ext/sockets/sendrecvmsg.c
@@ -66,12 +66,11 @@ inline ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
}
#endif
-#define LONG_CHECK_VALID_INT(l) \
+#define LONG_CHECK_VALID_INT(l, arg_pos) \
do { \
if ((l) < INT_MIN && (l) > INT_MAX) { \
- php_error_docref(NULL, E_WARNING, "The value " ZEND_LONG_FMT " does not fit inside " \
- "the boundaries of a native integer", (l)); \
- return; \
+ zend_argument_value_error((arg_pos), "must be between %d and %d", INT_MIN, INT_MAX); \
+ RETURN_THROWS(); \
} \
} while (0)
@@ -177,7 +176,7 @@ PHP_FUNCTION(socket_sendmsg)
RETURN_THROWS();
}
- LONG_CHECK_VALID_INT(flags);
+ LONG_CHECK_VALID_INT(flags, 3);
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
@@ -222,7 +221,7 @@ PHP_FUNCTION(socket_recvmsg)
RETURN_THROWS();
}
- LONG_CHECK_VALID_INT(flags);
+ LONG_CHECK_VALID_INT(flags, 3);
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
@@ -285,21 +284,20 @@ PHP_FUNCTION(socket_cmsg_space)
RETURN_THROWS();
}
- LONG_CHECK_VALID_INT(level);
- LONG_CHECK_VALID_INT(type);
- LONG_CHECK_VALID_INT(n);
+ LONG_CHECK_VALID_INT(level, 1);
+ LONG_CHECK_VALID_INT(type, 2);
+ LONG_CHECK_VALID_INT(n, 3);
if (n < 0) {
- php_error_docref(NULL, E_WARNING, "The third argument "
- "cannot be negative");
- return;
+ zend_argument_value_error(3, "must be greater or equal than 0");
+ RETURN_THROWS();
}
entry = get_ancillary_reg_entry(level, type);
if (entry == NULL) {
- php_error_docref(NULL, E_WARNING, "The pair level " ZEND_LONG_FMT "/type " ZEND_LONG_FMT " is "
- "not supported by PHP", level, type);
- return;
+ zend_value_error("Pair level " ZEND_LONG_FMT " and/or type " ZEND_LONG_FMT " is not supported",
+ level, type);
+ RETURN_THROWS();
}
if (entry->var_el_size > 0) {
@@ -310,9 +308,8 @@ PHP_FUNCTION(socket_cmsg_space)
if (n > n_max /* zend_long overflow */
|| total_size > ZEND_LONG_MAX
|| total_size < size /* align overflow */) {
- php_error_docref(NULL, E_WARNING, "The value for the "
- "third argument (" ZEND_LONG_FMT ") is too large", n);
- return;
+ zend_argument_value_error(3, "is too large");
+ RETURN_THROWS();
}
}
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 0009d35ece..e305bd4790 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -692,6 +692,7 @@ PHP_FUNCTION(socket_select)
}
if (!sets) {
+ /* TODO Convert to Error? */
php_error_docref(NULL, E_WARNING, "No resource arrays were passed to select");
RETURN_FALSE;
}
@@ -923,8 +924,8 @@ PHP_FUNCTION(socket_write)
}
if (length < 0) {
- php_error_docref(NULL, E_WARNING, "Length cannot be negative");
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
@@ -1078,8 +1079,8 @@ PHP_FUNCTION(socket_getsockname)
break;
default:
- php_error_docref(NULL, E_WARNING, "Unsupported address family %d", sa->sa_family);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
}
/* }}} */
@@ -1155,8 +1156,8 @@ PHP_FUNCTION(socket_getpeername)
break;
default:
- php_error_docref(NULL, E_WARNING, "Unsupported address family %d", sa->sa_family);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
}
/* }}} */
@@ -1165,30 +1166,33 @@ PHP_FUNCTION(socket_getpeername)
Creates an endpoint for communication in the domain specified by domain, of type specified by type */
PHP_FUNCTION(socket_create)
{
- zend_long arg1, arg2, arg3;
+ zend_long domain, type, protocol;
php_socket *php_sock = php_create_socket();
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &arg1, &arg2, &arg3) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &domain, &type, &protocol) == FAILURE) {
efree(php_sock);
RETURN_THROWS();
}
- if (arg1 != AF_UNIX
+ if (domain != AF_UNIX
#if HAVE_IPV6
- && arg1 != AF_INET6
+ && domain != AF_INET6
#endif
- && arg1 != AF_INET) {
- php_error_docref(NULL, E_WARNING, "Invalid socket domain [" ZEND_LONG_FMT "] specified for argument 1, assuming AF_INET", arg1);
- arg1 = AF_INET;
+ && domain != AF_INET) {
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET6 or AF_INET");
+ efree(php_sock);
+ RETURN_THROWS();
}
- if (arg2 > 10) {
- php_error_docref(NULL, E_WARNING, "Invalid socket type [" ZEND_LONG_FMT "] specified for argument 2, assuming SOCK_STREAM", arg2);
- arg2 = SOCK_STREAM;
+ if (type > 10) {
+ zend_argument_value_error(2, "must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET,"
+ " SOCK_RAW, or SOCK_RDM");
+ efree(php_sock);
+ RETURN_THROWS();
}
- php_sock->bsd_socket = socket(arg1, arg2, arg3);
- php_sock->type = arg1;
+ php_sock->bsd_socket = socket(domain, type, protocol);
+ php_sock->type = domain;
if (IS_INVALID_SOCKET(php_sock)) {
SOCKETS_G(last_error) = errno;
@@ -1208,19 +1212,18 @@ PHP_FUNCTION(socket_create)
Opens a connection to addr:port on the socket specified by socket */
PHP_FUNCTION(socket_connect)
{
- zval *arg1;
+ zval *resource_socket;
php_socket *php_sock;
char *addr;
int retval;
size_t addr_len;
zend_long port = 0;
- int argc = ZEND_NUM_ARGS();
- if (zend_parse_parameters(argc, "rs|l", &arg1, &addr, &addr_len, &port) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|l", &resource_socket, &addr, &addr_len, &port) == FAILURE) {
RETURN_THROWS();
}
- if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
+ if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(resource_socket), le_socket_name, le_socket)) == NULL) {
RETURN_THROWS();
}
@@ -1229,9 +1232,9 @@ PHP_FUNCTION(socket_connect)
case AF_INET6: {
struct sockaddr_in6 sin6 = {0};
- if (argc != 3) {
- php_error_docref(NULL, E_WARNING, "Socket of type AF_INET6 requires 3 arguments");
- RETURN_FALSE;
+ if (ZEND_NUM_ARGS() != 3) {
+ zend_argument_value_error(3, "must be specified for the AF_INET6 socket type");
+ RETURN_THROWS();
}
memset(&sin6, 0, sizeof(struct sockaddr_in6));
@@ -1250,9 +1253,9 @@ PHP_FUNCTION(socket_connect)
case AF_INET: {
struct sockaddr_in sin = {0};
- if (argc != 3) {
- php_error_docref(NULL, E_WARNING, "Socket of type AF_INET requires 3 arguments");
- RETURN_FALSE;
+ if (ZEND_NUM_ARGS() != 3) {
+ zend_argument_value_error(3, "must be specified for the AF_INET socket type");
+ RETURN_THROWS();
}
sin.sin_family = AF_INET;
@@ -1270,8 +1273,8 @@ PHP_FUNCTION(socket_connect)
struct sockaddr_un s_un = {0};
if (addr_len >= sizeof(s_un.sun_path)) {
- php_error_docref(NULL, E_WARNING, "Path too long");
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be less than %d", sizeof(s_un.sun_path));
+ RETURN_THROWS();
}
s_un.sun_family = AF_UNIX;
@@ -1282,8 +1285,8 @@ PHP_FUNCTION(socket_connect)
}
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
if (retval != 0) {
@@ -1338,10 +1341,8 @@ PHP_FUNCTION(socket_bind)
sa->sun_family = AF_UNIX;
if (addr_len >= sizeof(sa->sun_path)) {
- php_error_docref(NULL, E_WARNING,
- "Invalid path: too long (maximum size is %d)",
- (int)sizeof(sa->sun_path) - 1);
- RETURN_FALSE;
+ zend_argument_value_error(2, "must be less than %d", sizeof(sa->sun_path));
+ RETURN_THROWS();
}
memcpy(&sa->sun_path, addr, addr_len);
@@ -1381,12 +1382,12 @@ PHP_FUNCTION(socket_bind)
}
#endif
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
if (retval != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to bind address", errno);
RETURN_FALSE;
}
@@ -1429,7 +1430,7 @@ PHP_FUNCTION(socket_recv)
}
if (retval == -1) {
- PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to read from socket", errno);
RETURN_FALSE;
}
@@ -1452,8 +1453,8 @@ PHP_FUNCTION(socket_send)
}
if (len < 0) {
- php_error_docref(NULL, E_WARNING, "Length cannot be negative");
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
@@ -1463,7 +1464,7 @@ PHP_FUNCTION(socket_send)
retval = send(php_sock->bsd_socket, buf, (buf_len < (size_t)len ? buf_len : (size_t)len), flags);
if (retval == (size_t)-1) {
- PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to write to socket", errno);
RETURN_FALSE;
}
@@ -1498,6 +1499,7 @@ PHP_FUNCTION(socket_recvfrom)
}
/* overflow check */
+ /* Shouldthrow ? */
if ((arg3 + 2) < 3) {
RETURN_FALSE;
}
@@ -1513,7 +1515,7 @@ PHP_FUNCTION(socket_recvfrom)
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, (socklen_t *)&slen);
if (retval < 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to recvfrom", errno);
zend_string_efree(recv_buf);
RETURN_FALSE;
}
@@ -1537,7 +1539,7 @@ PHP_FUNCTION(socket_recvfrom)
retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen);
if (retval < 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to recvfrom", errno);
zend_string_efree(recv_buf);
RETURN_FALSE;
}
@@ -1580,8 +1582,8 @@ PHP_FUNCTION(socket_recvfrom)
break;
#endif
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
RETURN_LONG(retval);
@@ -1610,8 +1612,8 @@ PHP_FUNCTION(socket_sendto)
}
if (len < 0) {
- php_error_docref(NULL, E_WARNING, "Length cannot be negative");
- RETURN_FALSE;
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NULL) {
@@ -1660,12 +1662,12 @@ PHP_FUNCTION(socket_sendto)
break;
#endif
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
if (retval == -1) {
- PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to write to socket", errno);
RETURN_FALSE;
}
@@ -1703,7 +1705,7 @@ PHP_FUNCTION(socket_get_option)
unsigned int if_index;
optlen = sizeof(if_addr);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}
if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) {
@@ -1731,7 +1733,7 @@ PHP_FUNCTION(socket_get_option)
optlen = sizeof(linger_val);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}
@@ -1746,14 +1748,14 @@ PHP_FUNCTION(socket_get_option)
optlen = sizeof(tv);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}
#else
optlen = sizeof(int);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}
@@ -1771,7 +1773,7 @@ PHP_FUNCTION(socket_get_option)
optlen = sizeof(other_val);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}
if (optlen == 1)
@@ -1845,12 +1847,12 @@ PHP_FUNCTION(socket_set_option)
opt_ht = Z_ARRVAL_P(arg4);
if ((l_onoff = zend_hash_str_find(opt_ht, l_onoff_key, sizeof(l_onoff_key) - 1)) == NULL) {
- php_error_docref(NULL, E_WARNING, "No key \"%s\" passed in optval", l_onoff_key);
- RETURN_FALSE;
+ zend_argument_value_error(4, "must have key \"%s\"", l_onoff_key);
+ RETURN_THROWS();
}
if ((l_linger = zend_hash_str_find(opt_ht, l_linger_key, sizeof(l_linger_key) - 1)) == NULL) {
- php_error_docref(NULL, E_WARNING, "No key \"%s\" passed in optval", l_linger_key);
- RETURN_FALSE;
+ zend_argument_value_error(4, "must have key \"%s\"", l_linger_key);
+ RETURN_THROWS();
}
convert_to_long_ex(l_onoff);
@@ -1873,12 +1875,12 @@ PHP_FUNCTION(socket_set_option)
opt_ht = Z_ARRVAL_P(arg4);
if ((sec = zend_hash_str_find(opt_ht, sec_key, sizeof(sec_key) - 1)) == NULL) {
- php_error_docref(NULL, E_WARNING, "No key \"%s\" passed in optval", sec_key);
- RETURN_FALSE;
+ zend_argument_value_error(4, "must have key \"%s\"", sec_key);
+ RETURN_THROWS();
}
if ((usec = zend_hash_str_find(opt_ht, usec_key, sizeof(usec_key) - 1)) == NULL) {
- php_error_docref(NULL, E_WARNING, "No key \"%s\" passed in optval", usec_key);
- RETURN_FALSE;
+ zend_argument_value_error(4, "must have key \"%s\"", usec_key);
+ RETURN_THROWS();
}
convert_to_long_ex(sec);
@@ -1920,7 +1922,7 @@ default_case:
retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
if (retval != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to set socket option", errno);
RETURN_FALSE;
}
@@ -1942,23 +1944,24 @@ PHP_FUNCTION(socket_create_pair)
RETURN_THROWS();
}
- php_sock[0] = php_create_socket();
- php_sock[1] = php_create_socket();
-
if (domain != AF_INET
#if HAVE_IPV6
&& domain != AF_INET6
#endif
&& domain != AF_UNIX) {
- php_error_docref(NULL, E_WARNING, "Invalid socket domain [" ZEND_LONG_FMT "] specified for argument 1, assuming AF_INET", domain);
- domain = AF_INET;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET6 or AF_INET");
+ RETURN_THROWS();
}
if (type > 10) {
- php_error_docref(NULL, E_WARNING, "Invalid socket type [" ZEND_LONG_FMT "] specified for argument 2, assuming SOCK_STREAM", type);
- type = SOCK_STREAM;
+ zend_argument_value_error(2, "must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET,"
+ " SOCK_RAW, or SOCK_RDM");
+ RETURN_THROWS();
}
+ php_sock[0] = php_create_socket();
+ php_sock[1] = php_create_socket();
+
if (socketpair(domain, type, protocol, fds_array) != 0) {
SOCKETS_G(last_error) = errno;
php_error_docref(NULL, E_WARNING, "Unable to create socket pair [%d]: %s", errno, sockets_strerror(errno));
@@ -2012,7 +2015,7 @@ PHP_FUNCTION(socket_shutdown)
}
if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
- PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
+ PHP_SOCKET_ERROR(php_sock, "Unable to shutdown socket", errno);
RETURN_FALSE;
}
@@ -2092,7 +2095,7 @@ php_socket *socket_import_file_descriptor(PHP_SOCKET socket)
if (getsockname(socket, (struct sockaddr*)&addr, &addr_len) == 0) {
retsock->type = addr.ss_family;
} else {
- PHP_SOCKET_ERROR(retsock, "unable to obtain socket family", errno);
+ PHP_SOCKET_ERROR(retsock, "Unable to obtain socket family", errno);
goto error;
}
@@ -2100,7 +2103,7 @@ php_socket *socket_import_file_descriptor(PHP_SOCKET socket)
#ifndef PHP_WIN32
t = fcntl(socket, F_GETFL);
if (t == -1) {
- PHP_SOCKET_ERROR(retsock, "unable to obtain blocking state", errno);
+ PHP_SOCKET_ERROR(retsock, "Unable to obtain blocking state", errno);
goto error;
} else {
retsock->blocking = !(t & O_NONBLOCK);
@@ -2286,6 +2289,7 @@ PHP_FUNCTION(socket_addrinfo_lookup)
} else if (zend_string_equals_literal(key, "ai_family")) {
hints.ai_family = zval_get_long(hint);
} else {
+ /* TODO Promote to warning/error? */
php_error_docref(NULL, E_NOTICE, "Unknown hint %s", ZSTR_VAL(key));
}
}
@@ -2367,10 +2371,10 @@ PHP_FUNCTION(socket_addrinfo_bind)
break;
}
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
close(php_sock->bsd_socket);
efree(php_sock);
- RETURN_FALSE;
+ zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
+ RETURN_THROWS();
}
if (retval != 0) {
@@ -2433,10 +2437,10 @@ PHP_FUNCTION(socket_addrinfo_connect)
break;
}
default:
- php_error_docref(NULL, E_WARNING, "Unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
+ zend_argument_value_error(1, "socket type must be either AF_UNIX, AF_INET, or AF_INET6");
close(php_sock->bsd_socket);
efree(php_sock);
- RETURN_FALSE;
+ RETURN_THROWS();
}
if (retval != 0) {
diff --git a/ext/sockets/tests/mcast_ipv4_send_error.phpt b/ext/sockets/tests/mcast_ipv4_send_error.phpt
index 91063f4253..5d254c6843 100644
--- a/ext/sockets/tests/mcast_ipv4_send_error.phpt
+++ b/ext/sockets/tests/mcast_ipv4_send_error.phpt
@@ -38,8 +38,12 @@ echo "\n";
echo "Setting IP_MULTICAST_TTL with 256\n";
//if we had a simple cast to unsigned char, this would be the same as 0
-$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256);
-var_dump($r);
+try {
+ $r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256);
+ var_dump($r);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r);
echo "\n";
@@ -53,12 +57,16 @@ echo "\n";
echo "Setting IP_MULTICAST_TTL with -1\n";
//should give error, not be the same as 255
-$r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1);
-var_dump($r);
+try {
+ $r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1);
+ var_dump($r);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r);
echo "\n";
---EXPECTF--
+--EXPECT--
Setting IP_MULTICAST_LOOP with 256
bool(true)
int(1)
@@ -68,9 +76,7 @@ bool(true)
int(0)
Setting IP_MULTICAST_TTL with 256
-
-Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
-bool(false)
+socket_set_option(): Argument #4 ($optval) must be between 0 and 255
int(1)
Setting IP_MULTICAST_TTL with "254"
@@ -78,7 +84,5 @@ bool(true)
int(254)
Setting IP_MULTICAST_TTL with -1
-
-Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
-bool(false)
+socket_set_option(): Argument #4 ($optval) must be between 0 and 255
int(254)
diff --git a/ext/sockets/tests/socket_connect_params.phpt b/ext/sockets/tests/socket_connect_params.phpt
index 3d3b759a14..ea7c4971d1 100644
--- a/ext/sockets/tests/socket_connect_params.phpt
+++ b/ext/sockets/tests/socket_connect_params.phpt
@@ -18,10 +18,14 @@ socket_getsockname($s_c, $addr, $port);
// wrong parameter count
try {
$s_w = socket_connect($s_c);
-} catch (TypeError $e) {
- echo $e->getMessage(), "\n";
+} catch (\ArgumentCountError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ $s_w = socket_connect($s_c, '0.0.0.0');
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
}
-$s_w = socket_connect($s_c, '0.0.0.0');
$s_w = socket_connect($s_c, '0.0.0.0', $port);
socket_close($s_c);
@@ -29,7 +33,6 @@ socket_close($s_c);
?>
--EXPECTF--
socket_connect() expects at least 2 parameters, 1 given
-
-Warning: socket_connect(): Socket of type AF_INET requires 3 arguments in %s on line %d
+socket_connect(): Argument #3 ($port) must be specified for the AF_INET socket type
Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d
diff --git a/ext/sockets/tests/socket_create_pair-wrongparams-win32.phpt b/ext/sockets/tests/socket_create_pair-wrongparams-win32.phpt
index 9216a87046..de939f6657 100644
--- a/ext/sockets/tests/socket_create_pair-wrongparams-win32.phpt
+++ b/ext/sockets/tests/socket_create_pair-wrongparams-win32.phpt
@@ -13,17 +13,21 @@ if (!extension_loaded('sockets')) {
var_dump(socket_create_pair(AF_INET, null, null, $sockets));
-var_dump(socket_create_pair(31337, null, null, $sockets));
-
-var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
---EXPECTF--
-bool(true)
-
-Warning: socket_create_pair(): Invalid socket domain [31337] specified for argument 1, assuming AF_INET in %s on line %d
-bool(true)
+try {
+ var_dump(socket_create_pair(31337, null, null, $sockets));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
-Warning: socket_create_pair(): Invalid socket type [31337] specified for argument 2, assuming SOCK_STREAM in %s on line %d
+try {
+ var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+--EXPECT--
bool(true)
+socket_create_pair(): Argument #1 ($domain) must be either AF_UNIX, AF_INET6 or AF_INET
+socket_create_pair(): Argument #2 ($type) must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM
--CREDITS--
Till Klampaeckel, till@php.net
Berlin TestFest 2009
diff --git a/ext/sockets/tests/socket_create_pair-wrongparams.phpt b/ext/sockets/tests/socket_create_pair-wrongparams.phpt
index a7bc17b86b..7adbc91d8a 100644
--- a/ext/sockets/tests/socket_create_pair-wrongparams.phpt
+++ b/ext/sockets/tests/socket_create_pair-wrongparams.phpt
@@ -13,24 +13,24 @@ if (!extension_loaded('sockets')) {
var_dump(socket_create_pair(AF_INET, null, null, $sockets));
-var_dump(socket_create_pair(31337, null, null, $sockets));
+try {
+ var_dump(socket_create_pair(31337, null, null, $sockets));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
-var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
+try {
+ var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--EXPECTF--
Warning: socket_create_pair(): Unable to create socket pair [%d]: %s not supported in %s on line %d
bool(false)
-
-Warning: socket_create_pair(): Invalid socket domain [31337] specified for argument 1, assuming AF_INET in %s on line %d
-
-Warning: socket_create_pair(): Unable to create socket pair [%d]: %s not supported in %s on line %d
-bool(false)
-
-Warning: socket_create_pair(): Invalid socket type [31337] specified for argument 2, assuming SOCK_STREAM in %s on line %d
-
-Warning: socket_create_pair(): Unable to create socket pair [%d]: %s not supported %s on line %d
-bool(false)
+socket_create_pair(): Argument #1 ($domain) must be either AF_UNIX, AF_INET6 or AF_INET
+socket_create_pair(): Argument #2 ($type) must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM
--CREDITS--
Till Klampaeckel, till@php.net
Berlin TestFest 2009
diff --git a/ext/sockets/tests/socket_export_stream-4-win.phpt b/ext/sockets/tests/socket_export_stream-4-win.phpt
index 24fc604f6e..6865a880b1 100644
--- a/ext/sockets/tests/socket_export_stream-4-win.phpt
+++ b/ext/sockets/tests/socket_export_stream-4-win.phpt
@@ -73,8 +73,6 @@ socket_bind($sock4, '0.0.0.0', 0);
$stream4 = socket_export_stream($sock4);
socket_close($sock4);
test($stream4, $sock4);
-
-echo "Done.\n";
--EXPECTF--
normal
stream_set_blocking 1
@@ -99,7 +97,7 @@ Warning: socket_set_block(): unable to set blocking mode [%d]: An operation was
in %s on line %d
socket_get_option
-Warning: socket_get_option(): unable to retrieve socket option [%d]: An operation was attempted on something that is not a socket.
+Warning: socket_get_option(): Unable to retrieve socket option [%d]: An operation was attempted on something that is not a socket.
in %s on line %d
@@ -110,6 +108,3 @@ stream_set_blocking stream_set_blocking(): supplied resource is not a valid stre
socket_set_block socket_set_block(): supplied resource is not a valid Socket resource
socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
-
-
-Done.
diff --git a/ext/sockets/tests/socket_export_stream-4.phpt b/ext/sockets/tests/socket_export_stream-4.phpt
index 77050f02f4..6acc88d16b 100644
--- a/ext/sockets/tests/socket_export_stream-4.phpt
+++ b/ext/sockets/tests/socket_export_stream-4.phpt
@@ -98,7 +98,7 @@ socket_set_block
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
socket_get_option
-Warning: socket_get_option(): unable to retrieve socket option [%d]: %s in %s on line %d
+Warning: socket_get_option(): Unable to retrieve socket option [%d]: %s in %s on line %d
diff --git a/ext/sockets/tests/socket_import_stream-4-win.phpt b/ext/sockets/tests/socket_import_stream-4-win.phpt
index 16a9c0087e..8040572597 100644
--- a/ext/sockets/tests/socket_import_stream-4-win.phpt
+++ b/ext/sockets/tests/socket_import_stream-4-win.phpt
@@ -68,8 +68,6 @@ $stream4 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVE
$sock4 = socket_import_stream($stream4);
socket_close($sock4);
test($stream4, $sock4);
-
-echo "Done.\n";
--EXPECTF--
normal
stream_set_blocking 1
@@ -94,7 +92,7 @@ Warning: socket_set_block(): unable to set blocking mode [10038]: %s
in %ssocket_import_stream-4-win.php on line %d
socket_get_option
-Warning: socket_get_option(): unable to retrieve socket option [10038]: %s
+Warning: socket_get_option(): Unable to retrieve socket option [10038]: %s
in %ssocket_import_stream-4-win.php on line %d
@@ -105,6 +103,3 @@ stream_set_blocking stream_set_blocking(): supplied resource is not a valid stre
socket_set_block socket_set_block(): supplied resource is not a valid Socket resource
socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
-
-
-Done.
diff --git a/ext/sockets/tests/socket_import_stream-4.phpt b/ext/sockets/tests/socket_import_stream-4.phpt
index d0ccf6b71e..a4c38b5a1b 100644
--- a/ext/sockets/tests/socket_import_stream-4.phpt
+++ b/ext/sockets/tests/socket_import_stream-4.phpt
@@ -93,7 +93,7 @@ socket_set_block
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
socket_get_option
-Warning: socket_get_option(): unable to retrieve socket option [%d]: %s in %s on line %d
+Warning: socket_get_option(): Unable to retrieve socket option [%d]: %s in %s on line %d
diff --git a/ext/sockets/tests/socket_send_params.phpt b/ext/sockets/tests/socket_send_params.phpt
index cc05288eb9..4c3f57729f 100644
--- a/ext/sockets/tests/socket_send_params.phpt
+++ b/ext/sockets/tests/socket_send_params.phpt
@@ -9,8 +9,12 @@ ext/sockets - socket_send - test with incorrect parameters
--FILE--
<?php
$s_c = socket_create_listen(0);
- $s_w = socket_send($s_c, "foo", -1, MSG_OOB);
+ try {
+ $s_w = socket_send($s_c, "foo", -1, MSG_OOB);
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
socket_close($s_c);
?>
---EXPECTF--
-Warning: socket_send(): Length cannot be negative in %s on line %i
+--EXPECT--
+socket_send(): Argument #3 ($len) must be greater than or equal to 0
diff --git a/ext/sockets/tests/socket_sendto_params.phpt b/ext/sockets/tests/socket_sendto_params.phpt
index e4808a93ee..09cb859ad7 100644
--- a/ext/sockets/tests/socket_sendto_params.phpt
+++ b/ext/sockets/tests/socket_sendto_params.phpt
@@ -9,8 +9,12 @@ ext/sockets - socket_sendto - test with incorrect parameters
--FILE--
<?php
$s_c = socket_create_listen(0);
- $s_w = socket_sendto($s_c, "foo", -1, MSG_OOB, '127.0.0.1');
+ try {
+ $s_w = socket_sendto($s_c, "foo", -1, MSG_OOB, '127.0.0.1');
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
socket_close($s_c);
?>
---EXPECTF--
-Warning: socket_sendto(): Length cannot be negative in %s on line %i
+--EXPECT--
+socket_sendto(): Argument #3 ($len) must be greater than or equal to 0
diff --git a/ext/sockets/tests/socket_set_option_error_socket_option.phpt b/ext/sockets/tests/socket_set_option_error_socket_option.phpt
index 53d76fa4c1..d1d9c842ae 100644
--- a/ext/sockets/tests/socket_set_option_error_socket_option.phpt
+++ b/ext/sockets/tests/socket_set_option_error_socket_option.phpt
@@ -28,7 +28,7 @@ socket_set_option( $socket, SOL_SOCKET, 1, 1);
socket_close($socket);
?>
--EXPECTF--
-Warning: socket_set_option(): unable to set socket option [%d]: Permission denied in %s on line %d
+Warning: socket_set_option(): Unable to set socket option [%d]: Permission denied in %s on line %d
--CREDITS--
Moritz Neuhaeuser, info@xcompile.net
PHP Testfest Berlin 2009-05-10
diff --git a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
index 07238aa9e4..819d0ee443 100644
--- a/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_rcvtimeo.phpt
@@ -18,7 +18,11 @@ if (!$socket) {
socket_set_block($socket);
//wrong params
-$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_RCVTIMEO, array());
+try {
+ $retval_1 = socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, []);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
//set/get comparison
$options = array("sec" => 1, "usec" => 0);
@@ -29,8 +33,8 @@ var_dump($retval_2);
var_dump($retval_3 === $options);
socket_close($socket);
?>
---EXPECTF--
-Warning: socket_set_option(): No key "sec" passed in optval in %s on line %d
+--EXPECT--
+socket_set_option(): Argument #4 ($optval) must have key "sec"
bool(true)
bool(true)
--CREDITS--
diff --git a/ext/sockets/tests/socket_set_option_seolinger.phpt b/ext/sockets/tests/socket_set_option_seolinger.phpt
index d284a37f63..132d4e0c6e 100644
--- a/ext/sockets/tests/socket_set_option_seolinger.phpt
+++ b/ext/sockets/tests/socket_set_option_seolinger.phpt
@@ -18,7 +18,11 @@ if (!$socket) {
die('Unable to create AF_INET socket [socket]');
}
// wrong params
-$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, array());
+try {
+ $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_LINGER, []);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
// set/get comparison
$options = array("l_onoff" => 1, "l_linger" => 1);
@@ -27,7 +31,11 @@ $retval_3 = socket_get_option( $socket, SOL_SOCKET, SO_LINGER);
//l_linger not given
$options_2 = array("l_onoff" => 1);
-var_dump(socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_2));
+try {
+ var_dump(socket_set_option( $socket, SOL_SOCKET, SO_LINGER, $options_2));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump($retval_2);
var_dump($retval_3["l_linger"] === $options["l_linger"]);
@@ -36,11 +44,9 @@ var_dump((bool)$retval_3["l_onoff"] === (bool)$options["l_onoff"]);
socket_close($socket);
?>
---EXPECTF--
-Warning: socket_set_option(): No key "l_onoff" passed in optval in %s on line %d
-
-Warning: socket_set_option(): No key "l_linger" passed in optval in %s on line %d
-bool(false)
+--EXPECT--
+socket_set_option(): Argument #4 ($optval) must have key "l_onoff"
+socket_set_option(): Argument #4 ($optval) must have key "l_linger"
bool(true)
bool(true)
bool(true)
diff --git a/ext/sockets/tests/socket_set_option_sndtimeo.phpt b/ext/sockets/tests/socket_set_option_sndtimeo.phpt
index 9c79fd8270..359aab9ae9 100644
--- a/ext/sockets/tests/socket_set_option_sndtimeo.phpt
+++ b/ext/sockets/tests/socket_set_option_sndtimeo.phpt
@@ -18,7 +18,11 @@ if (!$socket) {
socket_set_block($socket);
//wrong params
-$retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, array());
+try {
+ $retval_1 = socket_set_option( $socket, SOL_SOCKET, SO_SNDTIMEO, []);
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
//set/get comparison
$options = array("sec" => 1, "usec" => 0);
@@ -29,8 +33,8 @@ var_dump($retval_2);
var_dump($retval_3 === $options);
socket_close($socket);
?>
---EXPECTF--
-Warning: socket_set_option(): No key "sec" passed in optval in %s on line %d
+--EXPECT--
+socket_set_option(): Argument #4 ($optval) must have key "sec"
bool(true)
bool(true)
--CREDITS--
diff --git a/ext/sockets/tests/socket_shutdown-win32.phpt b/ext/sockets/tests/socket_shutdown-win32.phpt
index 6280e61044..aced74b7f8 100644
--- a/ext/sockets/tests/socket_shutdown-win32.phpt
+++ b/ext/sockets/tests/socket_shutdown-win32.phpt
@@ -50,10 +50,10 @@ bool(true)
bool(true)
bool(true)
-Warning: socket_shutdown(): unable to shutdown socket [%d]: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
+Warning: socket_shutdown(): Unable to shutdown socket [%d]: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
in %s on line %d
bool(false)
-Warning: socket_shutdown(): unable to shutdown socket [%d]: An invalid argument was supplied.
+Warning: socket_shutdown(): Unable to shutdown socket [%d]: An invalid argument was supplied.
in %s on line %d
bool(false)
diff --git a/ext/sockets/tests/socket_shutdown.phpt b/ext/sockets/tests/socket_shutdown.phpt
index 747016b795..554958a77a 100644
--- a/ext/sockets/tests/socket_shutdown.phpt
+++ b/ext/sockets/tests/socket_shutdown.phpt
@@ -51,8 +51,8 @@ bool(true)
bool(true)
bool(true)
-Warning: socket_shutdown(): unable to shutdown socket [%d]: Transport endpoint is not connected in %s on line %d
+Warning: socket_shutdown(): Unable to shutdown socket [%d]: Transport endpoint is not connected in %s on line %d
bool(false)
-Warning: socket_shutdown(): unable to shutdown socket [%d]: Invalid argument in %s on line %d
+Warning: socket_shutdown(): Unable to shutdown socket [%d]: Invalid argument in %s on line %d
bool(false)