Promote warnings to Errors in sockets's extension.

This commit is contained in:
George Peter Banyard 2020-01-10 15:54:08 +01:00
parent 2aa661887f
commit 7ff8eaa545
19 changed files with 205 additions and 187 deletions

View file

@ -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_TYPE_P(val) == IS_LONG) {
if (Z_LVAL_P(val) < 0 || (zend_ulong)Z_LVAL_P(val) > UINT_MAX) { if (Z_LVAL_P(val) < 0 || (zend_ulong)Z_LVAL_P(val) > UINT_MAX) {
php_error_docref(NULL, E_WARNING, zend_value_error("Index must be between 0 and %u", UINT_MAX);
"The interface index cannot be negative or larger than %u;" return FAILURE;
" given " ZEND_LONG_FMT, UINT_MAX, Z_LVAL_P(val));
ret = FAILURE;
} else {
*out = Z_LVAL_P(val);
ret = SUCCESS;
} }
*out = Z_LVAL_P(val);
ret = SUCCESS;
} else { } else {
zend_string *tmp_str; zend_string *tmp_str;
zend_string *str = zval_get_tmp_string(val, &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; zend_string *str, *tmp_str;
if ((val = zend_hash_str_find(ht, key, strlen(key))) == NULL) { 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; return FAILURE;
} }
str = zval_get_tmp_string(val, &tmp_str); 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: case IP_MULTICAST_TTL:
convert_to_long_ex(arg4); convert_to_long_ex(arg4);
if (Z_LVAL_P(arg4) < 0L || Z_LVAL_P(arg4) > 255L) { if (Z_LVAL_P(arg4) < 0L || Z_LVAL_P(arg4) > 255L) {
php_error_docref(NULL, E_WARNING, zend_argument_value_error(4, "must be between 0 and 255");
"Expected a value between 0 and 255");
return FAILURE; return FAILURE;
} }
ipv4_mcast_ttl_lback = (unsigned char) Z_LVAL_P(arg4); 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: case IPV6_MULTICAST_HOPS:
convert_to_long_ex(arg4); convert_to_long_ex(arg4);
if (Z_LVAL_P(arg4) < -1L || Z_LVAL_P(arg4) > 255L) { if (Z_LVAL_P(arg4) < -1L || Z_LVAL_P(arg4) > 255L) {
php_error_docref(NULL, E_WARNING, zend_argument_value_error(4, "must be between -1 and 255");
"Expected a value between -1 and 255");
return FAILURE; return FAILURE;
} }
ov = (int) Z_LVAL_P(arg4); ov = (int) Z_LVAL_P(arg4);
@ -496,8 +491,7 @@ static int _php_mcast_join_leave(
} }
#endif #endif
else { else {
php_error_docref(NULL, E_WARNING, zend_value_error("Option %s is inapplicable to this socket type",
"Option %s is inapplicable to this socket type",
join ? "MCAST_JOIN_GROUP" : "MCAST_LEAVE_GROUP"); join ? "MCAST_JOIN_GROUP" : "MCAST_LEAVE_GROUP");
return -2; return -2;
} }

View file

@ -66,12 +66,11 @@ inline ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
} }
#endif #endif
#define LONG_CHECK_VALID_INT(l) \ #define LONG_CHECK_VALID_INT(l, arg_pos) \
do { \ do { \
if ((l) < INT_MIN && (l) > INT_MAX) { \ if ((l) < INT_MIN && (l) > INT_MAX) { \
php_error_docref(NULL, E_WARNING, "The value " ZEND_LONG_FMT " does not fit inside " \ zend_argument_value_error((arg_pos), "must be between %d and %d", INT_MIN, INT_MAX); \
"the boundaries of a native integer", (l)); \ RETURN_THROWS(); \
return; \
} \ } \
} while (0) } while (0)
@ -177,7 +176,7 @@ PHP_FUNCTION(socket_sendmsg)
RETURN_THROWS(); 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), if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) { php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
@ -222,7 +221,7 @@ PHP_FUNCTION(socket_recvmsg)
RETURN_THROWS(); 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), if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) { php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
@ -285,21 +284,20 @@ PHP_FUNCTION(socket_cmsg_space)
RETURN_THROWS(); RETURN_THROWS();
} }
LONG_CHECK_VALID_INT(level); LONG_CHECK_VALID_INT(level, 1);
LONG_CHECK_VALID_INT(type); LONG_CHECK_VALID_INT(type, 2);
LONG_CHECK_VALID_INT(n); LONG_CHECK_VALID_INT(n, 3);
if (n < 0) { if (n < 0) {
php_error_docref(NULL, E_WARNING, "The third argument " zend_argument_value_error(3, "must be greater or equal than 0");
"cannot be negative"); RETURN_THROWS();
return;
} }
entry = get_ancillary_reg_entry(level, type); entry = get_ancillary_reg_entry(level, type);
if (entry == NULL) { if (entry == NULL) {
php_error_docref(NULL, E_WARNING, "The pair level " ZEND_LONG_FMT "/type " ZEND_LONG_FMT " is " zend_value_error("Pair level " ZEND_LONG_FMT " and/or type " ZEND_LONG_FMT " is not supported",
"not supported by PHP", level, type); level, type);
return; RETURN_THROWS();
} }
if (entry->var_el_size > 0) { if (entry->var_el_size > 0) {
@ -310,9 +308,8 @@ PHP_FUNCTION(socket_cmsg_space)
if (n > n_max /* zend_long overflow */ if (n > n_max /* zend_long overflow */
|| total_size > ZEND_LONG_MAX || total_size > ZEND_LONG_MAX
|| total_size < size /* align overflow */) { || total_size < size /* align overflow */) {
php_error_docref(NULL, E_WARNING, "The value for the " zend_argument_value_error(3, "is too large");
"third argument (" ZEND_LONG_FMT ") is too large", n); RETURN_THROWS();
return;
} }
} }

View file

@ -692,6 +692,7 @@ PHP_FUNCTION(socket_select)
} }
if (!sets) { if (!sets) {
/* TODO Convert to Error? */
php_error_docref(NULL, E_WARNING, "No resource arrays were passed to select"); php_error_docref(NULL, E_WARNING, "No resource arrays were passed to select");
RETURN_FALSE; RETURN_FALSE;
} }
@ -923,8 +924,8 @@ PHP_FUNCTION(socket_write)
} }
if (length < 0) { if (length < 0) {
php_error_docref(NULL, E_WARNING, "Length cannot be negative"); zend_argument_value_error(3, "must be greater than or equal to 0");
RETURN_FALSE; 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(arg1), le_socket_name, le_socket)) == NULL) {
@ -1078,8 +1079,8 @@ PHP_FUNCTION(socket_getsockname)
break; break;
default: default:
php_error_docref(NULL, E_WARNING, "Unsupported address family %d", sa->sa_family); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; RETURN_THROWS();
} }
} }
/* }}} */ /* }}} */
@ -1155,8 +1156,8 @@ PHP_FUNCTION(socket_getpeername)
break; break;
default: default:
php_error_docref(NULL, E_WARNING, "Unsupported address family %d", sa->sa_family); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; 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 */ Creates an endpoint for communication in the domain specified by domain, of type specified by type */
PHP_FUNCTION(socket_create) PHP_FUNCTION(socket_create)
{ {
zend_long arg1, arg2, arg3; zend_long domain, type, protocol;
php_socket *php_sock = php_create_socket(); 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); efree(php_sock);
RETURN_THROWS(); RETURN_THROWS();
} }
if (arg1 != AF_UNIX if (domain != AF_UNIX
#if HAVE_IPV6 #if HAVE_IPV6
&& arg1 != AF_INET6 && domain != AF_INET6
#endif #endif
&& arg1 != AF_INET) { && domain != AF_INET) {
php_error_docref(NULL, E_WARNING, "Invalid socket domain [" ZEND_LONG_FMT "] specified for argument 1, assuming AF_INET", arg1); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET6 or AF_INET");
arg1 = AF_INET; efree(php_sock);
RETURN_THROWS();
} }
if (arg2 > 10) { if (type > 10) {
php_error_docref(NULL, E_WARNING, "Invalid socket type [" ZEND_LONG_FMT "] specified for argument 2, assuming SOCK_STREAM", arg2); zend_argument_value_error(2, "must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET,"
arg2 = SOCK_STREAM; " SOCK_RAW, or SOCK_RDM");
efree(php_sock);
RETURN_THROWS();
} }
php_sock->bsd_socket = socket(arg1, arg2, arg3); php_sock->bsd_socket = socket(domain, type, protocol);
php_sock->type = arg1; php_sock->type = domain;
if (IS_INVALID_SOCKET(php_sock)) { if (IS_INVALID_SOCKET(php_sock)) {
SOCKETS_G(last_error) = errno; 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 */ Opens a connection to addr:port on the socket specified by socket */
PHP_FUNCTION(socket_connect) PHP_FUNCTION(socket_connect)
{ {
zval *arg1; zval *resource_socket;
php_socket *php_sock; php_socket *php_sock;
char *addr; char *addr;
int retval; int retval;
size_t addr_len; size_t addr_len;
zend_long port = 0; 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(); 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(); RETURN_THROWS();
} }
@ -1229,9 +1232,9 @@ PHP_FUNCTION(socket_connect)
case AF_INET6: { case AF_INET6: {
struct sockaddr_in6 sin6 = {0}; struct sockaddr_in6 sin6 = {0};
if (argc != 3) { if (ZEND_NUM_ARGS() != 3) {
php_error_docref(NULL, E_WARNING, "Socket of type AF_INET6 requires 3 arguments"); zend_argument_value_error(3, "must be specified for the AF_INET6 socket type");
RETURN_FALSE; RETURN_THROWS();
} }
memset(&sin6, 0, sizeof(struct sockaddr_in6)); memset(&sin6, 0, sizeof(struct sockaddr_in6));
@ -1250,9 +1253,9 @@ PHP_FUNCTION(socket_connect)
case AF_INET: { case AF_INET: {
struct sockaddr_in sin = {0}; struct sockaddr_in sin = {0};
if (argc != 3) { if (ZEND_NUM_ARGS() != 3) {
php_error_docref(NULL, E_WARNING, "Socket of type AF_INET requires 3 arguments"); zend_argument_value_error(3, "must be specified for the AF_INET socket type");
RETURN_FALSE; RETURN_THROWS();
} }
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
@ -1270,8 +1273,8 @@ PHP_FUNCTION(socket_connect)
struct sockaddr_un s_un = {0}; struct sockaddr_un s_un = {0};
if (addr_len >= sizeof(s_un.sun_path)) { if (addr_len >= sizeof(s_un.sun_path)) {
php_error_docref(NULL, E_WARNING, "Path too long"); zend_argument_value_error(2, "must be less than %d", sizeof(s_un.sun_path));
RETURN_FALSE; RETURN_THROWS();
} }
s_un.sun_family = AF_UNIX; s_un.sun_family = AF_UNIX;
@ -1282,8 +1285,8 @@ PHP_FUNCTION(socket_connect)
} }
default: default:
php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; RETURN_THROWS();
} }
if (retval != 0) { if (retval != 0) {
@ -1338,10 +1341,8 @@ PHP_FUNCTION(socket_bind)
sa->sun_family = AF_UNIX; sa->sun_family = AF_UNIX;
if (addr_len >= sizeof(sa->sun_path)) { if (addr_len >= sizeof(sa->sun_path)) {
php_error_docref(NULL, E_WARNING, zend_argument_value_error(2, "must be less than %d", sizeof(sa->sun_path));
"Invalid path: too long (maximum size is %d)", RETURN_THROWS();
(int)sizeof(sa->sun_path) - 1);
RETURN_FALSE;
} }
memcpy(&sa->sun_path, addr, addr_len); memcpy(&sa->sun_path, addr, addr_len);
@ -1381,12 +1382,12 @@ PHP_FUNCTION(socket_bind)
} }
#endif #endif
default: 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, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; RETURN_THROWS();
} }
if (retval != 0) { 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; RETURN_FALSE;
} }
@ -1429,7 +1430,7 @@ PHP_FUNCTION(socket_recv)
} }
if (retval == -1) { 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; RETURN_FALSE;
} }
@ -1452,8 +1453,8 @@ PHP_FUNCTION(socket_send)
} }
if (len < 0) { if (len < 0) {
php_error_docref(NULL, E_WARNING, "Length cannot be negative"); zend_argument_value_error(3, "must be greater than or equal to 0");
RETURN_FALSE; 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(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); retval = send(php_sock->bsd_socket, buf, (buf_len < (size_t)len ? buf_len : (size_t)len), flags);
if (retval == (size_t)-1) { 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; RETURN_FALSE;
} }
@ -1498,6 +1499,7 @@ PHP_FUNCTION(socket_recvfrom)
} }
/* overflow check */ /* overflow check */
/* Shouldthrow ? */
if ((arg3 + 2) < 3) { if ((arg3 + 2) < 3) {
RETURN_FALSE; 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); retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, (socklen_t *)&slen);
if (retval < 0) { 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); zend_string_efree(recv_buf);
RETURN_FALSE; 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); retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (socklen_t *)&slen);
if (retval < 0) { 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); zend_string_efree(recv_buf);
RETURN_FALSE; RETURN_FALSE;
} }
@ -1580,8 +1582,8 @@ PHP_FUNCTION(socket_recvfrom)
break; break;
#endif #endif
default: default:
php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; RETURN_THROWS();
} }
RETURN_LONG(retval); RETURN_LONG(retval);
@ -1610,8 +1612,8 @@ PHP_FUNCTION(socket_sendto)
} }
if (len < 0) { if (len < 0) {
php_error_docref(NULL, E_WARNING, "Length cannot be negative"); zend_argument_value_error(3, "must be greater than or equal to 0");
RETURN_FALSE; 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(arg1), le_socket_name, le_socket)) == NULL) {
@ -1660,12 +1662,12 @@ PHP_FUNCTION(socket_sendto)
break; break;
#endif #endif
default: default:
php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET, or AF_INET6");
RETURN_FALSE; RETURN_THROWS();
} }
if (retval == -1) { 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; RETURN_FALSE;
} }
@ -1703,7 +1705,7 @@ PHP_FUNCTION(socket_get_option)
unsigned int if_index; unsigned int if_index;
optlen = sizeof(if_addr); optlen = sizeof(if_addr);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) { 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; RETURN_FALSE;
} }
if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) { 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); optlen = sizeof(linger_val);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) { 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; RETURN_FALSE;
} }
@ -1746,14 +1748,14 @@ PHP_FUNCTION(socket_get_option)
optlen = sizeof(tv); optlen = sizeof(tv);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) { 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; RETURN_FALSE;
} }
#else #else
optlen = sizeof(int); optlen = sizeof(int);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) { 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; RETURN_FALSE;
} }
@ -1771,7 +1773,7 @@ PHP_FUNCTION(socket_get_option)
optlen = sizeof(other_val); optlen = sizeof(other_val);
if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) { 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; RETURN_FALSE;
} }
if (optlen == 1) if (optlen == 1)
@ -1845,12 +1847,12 @@ PHP_FUNCTION(socket_set_option)
opt_ht = Z_ARRVAL_P(arg4); opt_ht = Z_ARRVAL_P(arg4);
if ((l_onoff = zend_hash_str_find(opt_ht, l_onoff_key, sizeof(l_onoff_key) - 1)) == NULL) { 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); zend_argument_value_error(4, "must have key \"%s\"", l_onoff_key);
RETURN_FALSE; RETURN_THROWS();
} }
if ((l_linger = zend_hash_str_find(opt_ht, l_linger_key, sizeof(l_linger_key) - 1)) == NULL) { 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); zend_argument_value_error(4, "must have key \"%s\"", l_linger_key);
RETURN_FALSE; RETURN_THROWS();
} }
convert_to_long_ex(l_onoff); convert_to_long_ex(l_onoff);
@ -1873,12 +1875,12 @@ PHP_FUNCTION(socket_set_option)
opt_ht = Z_ARRVAL_P(arg4); opt_ht = Z_ARRVAL_P(arg4);
if ((sec = zend_hash_str_find(opt_ht, sec_key, sizeof(sec_key) - 1)) == NULL) { 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); zend_argument_value_error(4, "must have key \"%s\"", sec_key);
RETURN_FALSE; RETURN_THROWS();
} }
if ((usec = zend_hash_str_find(opt_ht, usec_key, sizeof(usec_key) - 1)) == NULL) { 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); zend_argument_value_error(4, "must have key \"%s\"", usec_key);
RETURN_FALSE; RETURN_THROWS();
} }
convert_to_long_ex(sec); convert_to_long_ex(sec);
@ -1920,7 +1922,7 @@ default_case:
retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen); retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
if (retval != 0) { 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; RETURN_FALSE;
} }
@ -1942,23 +1944,24 @@ PHP_FUNCTION(socket_create_pair)
RETURN_THROWS(); RETURN_THROWS();
} }
php_sock[0] = php_create_socket();
php_sock[1] = php_create_socket();
if (domain != AF_INET if (domain != AF_INET
#if HAVE_IPV6 #if HAVE_IPV6
&& domain != AF_INET6 && domain != AF_INET6
#endif #endif
&& domain != AF_UNIX) { && domain != AF_UNIX) {
php_error_docref(NULL, E_WARNING, "Invalid socket domain [" ZEND_LONG_FMT "] specified for argument 1, assuming AF_INET", domain); zend_argument_value_error(1, "must be either AF_UNIX, AF_INET6 or AF_INET");
domain = AF_INET; RETURN_THROWS();
} }
if (type > 10) { if (type > 10) {
php_error_docref(NULL, E_WARNING, "Invalid socket type [" ZEND_LONG_FMT "] specified for argument 2, assuming SOCK_STREAM", type); zend_argument_value_error(2, "must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET,"
type = SOCK_STREAM; " 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) { if (socketpair(domain, type, protocol, fds_array) != 0) {
SOCKETS_G(last_error) = errno; SOCKETS_G(last_error) = errno;
php_error_docref(NULL, E_WARNING, "Unable to create socket pair [%d]: %s", errno, sockets_strerror(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) { 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; RETURN_FALSE;
} }
@ -2092,7 +2095,7 @@ php_socket *socket_import_file_descriptor(PHP_SOCKET socket)
if (getsockname(socket, (struct sockaddr*)&addr, &addr_len) == 0) { if (getsockname(socket, (struct sockaddr*)&addr, &addr_len) == 0) {
retsock->type = addr.ss_family; retsock->type = addr.ss_family;
} else { } else {
PHP_SOCKET_ERROR(retsock, "unable to obtain socket family", errno); PHP_SOCKET_ERROR(retsock, "Unable to obtain socket family", errno);
goto error; goto error;
} }
@ -2100,7 +2103,7 @@ php_socket *socket_import_file_descriptor(PHP_SOCKET socket)
#ifndef PHP_WIN32 #ifndef PHP_WIN32
t = fcntl(socket, F_GETFL); t = fcntl(socket, F_GETFL);
if (t == -1) { 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; goto error;
} else { } else {
retsock->blocking = !(t & O_NONBLOCK); retsock->blocking = !(t & O_NONBLOCK);
@ -2286,6 +2289,7 @@ PHP_FUNCTION(socket_addrinfo_lookup)
} else if (zend_string_equals_literal(key, "ai_family")) { } else if (zend_string_equals_literal(key, "ai_family")) {
hints.ai_family = zval_get_long(hint); hints.ai_family = zval_get_long(hint);
} else { } else {
/* TODO Promote to warning/error? */
php_error_docref(NULL, E_NOTICE, "Unknown hint %s", ZSTR_VAL(key)); php_error_docref(NULL, E_NOTICE, "Unknown hint %s", ZSTR_VAL(key));
} }
} }
@ -2367,10 +2371,10 @@ PHP_FUNCTION(socket_addrinfo_bind)
break; break;
} }
default: 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); close(php_sock->bsd_socket);
efree(php_sock); 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) { if (retval != 0) {
@ -2433,10 +2437,10 @@ PHP_FUNCTION(socket_addrinfo_connect)
break; break;
} }
default: 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); close(php_sock->bsd_socket);
efree(php_sock); efree(php_sock);
RETURN_FALSE; RETURN_THROWS();
} }
if (retval != 0) { if (retval != 0) {

View file

@ -38,8 +38,12 @@ echo "\n";
echo "Setting IP_MULTICAST_TTL with 256\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 //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); try {
var_dump($r); $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); $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r); var_dump($r);
echo "\n"; echo "\n";
@ -53,12 +57,16 @@ echo "\n";
echo "Setting IP_MULTICAST_TTL with -1\n"; echo "Setting IP_MULTICAST_TTL with -1\n";
//should give error, not be the same as 255 //should give error, not be the same as 255
$r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1); try {
var_dump($r); $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); $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
var_dump($r); var_dump($r);
echo "\n"; echo "\n";
--EXPECTF-- --EXPECT--
Setting IP_MULTICAST_LOOP with 256 Setting IP_MULTICAST_LOOP with 256
bool(true) bool(true)
int(1) int(1)
@ -68,9 +76,7 @@ bool(true)
int(0) int(0)
Setting IP_MULTICAST_TTL with 256 Setting IP_MULTICAST_TTL with 256
socket_set_option(): Argument #4 ($optval) must be between 0 and 255
Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
bool(false)
int(1) int(1)
Setting IP_MULTICAST_TTL with "254" Setting IP_MULTICAST_TTL with "254"
@ -78,7 +84,5 @@ bool(true)
int(254) int(254)
Setting IP_MULTICAST_TTL with -1 Setting IP_MULTICAST_TTL with -1
socket_set_option(): Argument #4 ($optval) must be between 0 and 255
Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
bool(false)
int(254) int(254)

View file

@ -18,10 +18,14 @@ socket_getsockname($s_c, $addr, $port);
// wrong parameter count // wrong parameter count
try { try {
$s_w = socket_connect($s_c); $s_w = socket_connect($s_c);
} catch (TypeError $e) { } catch (\ArgumentCountError $e) {
echo $e->getMessage(), "\n"; 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); $s_w = socket_connect($s_c, '0.0.0.0', $port);
socket_close($s_c); socket_close($s_c);
@ -29,7 +33,6 @@ socket_close($s_c);
?> ?>
--EXPECTF-- --EXPECTF--
socket_connect() expects at least 2 parameters, 1 given socket_connect() expects at least 2 parameters, 1 given
socket_connect(): Argument #3 ($port) must be specified for the AF_INET socket type
Warning: socket_connect(): Socket of type AF_INET requires 3 arguments in %s on line %d
Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d

View file

@ -13,17 +13,21 @@ if (!extension_loaded('sockets')) {
var_dump(socket_create_pair(AF_INET, null, null, $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 {
--EXPECTF-- var_dump(socket_create_pair(AF_INET, 31337, 0, $sockets));
bool(true) } catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
Warning: socket_create_pair(): Invalid socket domain [31337] specified for argument 1, assuming AF_INET in %s on line %d }
bool(true) --EXPECT--
Warning: socket_create_pair(): Invalid socket type [31337] specified for argument 2, assuming SOCK_STREAM in %s on line %d
bool(true) 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-- --CREDITS--
Till Klampaeckel, till@php.net Till Klampaeckel, till@php.net
Berlin TestFest 2009 Berlin TestFest 2009

View file

@ -13,24 +13,24 @@ if (!extension_loaded('sockets')) {
var_dump(socket_create_pair(AF_INET, null, null, $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-- --EXPECTF--
Warning: socket_create_pair(): Unable to create socket pair [%d]: %s not supported 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) bool(false)
socket_create_pair(): Argument #1 ($domain) must be either AF_UNIX, AF_INET6 or AF_INET
Warning: socket_create_pair(): Invalid socket domain [31337] specified for argument 1, assuming AF_INET in %s on line %d socket_create_pair(): Argument #2 ($type) must be either SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, or SOCK_RDM
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)
--CREDITS-- --CREDITS--
Till Klampaeckel, till@php.net Till Klampaeckel, till@php.net
Berlin TestFest 2009 Berlin TestFest 2009

View file

@ -73,8 +73,6 @@ socket_bind($sock4, '0.0.0.0', 0);
$stream4 = socket_export_stream($sock4); $stream4 = socket_export_stream($sock4);
socket_close($sock4); socket_close($sock4);
test($stream4, $sock4); test($stream4, $sock4);
echo "Done.\n";
--EXPECTF-- --EXPECTF--
normal normal
stream_set_blocking 1 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 in %s on line %d
socket_get_option 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 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_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 socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
Done.

View file

@ -98,7 +98,7 @@ socket_set_block
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
socket_get_option 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

View file

@ -68,8 +68,6 @@ $stream4 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVE
$sock4 = socket_import_stream($stream4); $sock4 = socket_import_stream($stream4);
socket_close($sock4); socket_close($sock4);
test($stream4, $sock4); test($stream4, $sock4);
echo "Done.\n";
--EXPECTF-- --EXPECTF--
normal normal
stream_set_blocking 1 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 in %ssocket_import_stream-4-win.php on line %d
socket_get_option 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 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_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 socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
Done.

View file

@ -93,7 +93,7 @@ socket_set_block
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
socket_get_option 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

View file

@ -9,8 +9,12 @@ ext/sockets - socket_send - test with incorrect parameters
--FILE-- --FILE--
<?php <?php
$s_c = socket_create_listen(0); $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); socket_close($s_c);
?> ?>
--EXPECTF-- --EXPECT--
Warning: socket_send(): Length cannot be negative in %s on line %i socket_send(): Argument #3 ($len) must be greater than or equal to 0

View file

@ -9,8 +9,12 @@ ext/sockets - socket_sendto - test with incorrect parameters
--FILE-- --FILE--
<?php <?php
$s_c = socket_create_listen(0); $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); socket_close($s_c);
?> ?>
--EXPECTF-- --EXPECT--
Warning: socket_sendto(): Length cannot be negative in %s on line %i socket_sendto(): Argument #3 ($len) must be greater than or equal to 0

View file

@ -28,7 +28,7 @@ socket_set_option( $socket, SOL_SOCKET, 1, 1);
socket_close($socket); socket_close($socket);
?> ?>
--EXPECTF-- --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-- --CREDITS--
Moritz Neuhaeuser, info@xcompile.net Moritz Neuhaeuser, info@xcompile.net
PHP Testfest Berlin 2009-05-10 PHP Testfest Berlin 2009-05-10

View file

@ -18,7 +18,11 @@ if (!$socket) {
socket_set_block($socket); socket_set_block($socket);
//wrong params //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 //set/get comparison
$options = array("sec" => 1, "usec" => 0); $options = array("sec" => 1, "usec" => 0);
@ -29,8 +33,8 @@ var_dump($retval_2);
var_dump($retval_3 === $options); var_dump($retval_3 === $options);
socket_close($socket); socket_close($socket);
?> ?>
--EXPECTF-- --EXPECT--
Warning: socket_set_option(): No key "sec" passed in optval in %s on line %d socket_set_option(): Argument #4 ($optval) must have key "sec"
bool(true) bool(true)
bool(true) bool(true)
--CREDITS-- --CREDITS--

View file

@ -18,7 +18,11 @@ if (!$socket) {
die('Unable to create AF_INET socket [socket]'); die('Unable to create AF_INET socket [socket]');
} }
// wrong params // 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 // set/get comparison
$options = array("l_onoff" => 1, "l_linger" => 1); $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 //l_linger not given
$options_2 = array("l_onoff" => 1); $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_2);
var_dump($retval_3["l_linger"] === $options["l_linger"]); 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); socket_close($socket);
?> ?>
--EXPECTF-- --EXPECT--
Warning: socket_set_option(): No key "l_onoff" passed in optval in %s on line %d socket_set_option(): Argument #4 ($optval) must have key "l_onoff"
socket_set_option(): Argument #4 ($optval) must have key "l_linger"
Warning: socket_set_option(): No key "l_linger" passed in optval in %s on line %d
bool(false)
bool(true) bool(true)
bool(true) bool(true)
bool(true) bool(true)

View file

@ -18,7 +18,11 @@ if (!$socket) {
socket_set_block($socket); socket_set_block($socket);
//wrong params //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 //set/get comparison
$options = array("sec" => 1, "usec" => 0); $options = array("sec" => 1, "usec" => 0);
@ -29,8 +33,8 @@ var_dump($retval_2);
var_dump($retval_3 === $options); var_dump($retval_3 === $options);
socket_close($socket); socket_close($socket);
?> ?>
--EXPECTF-- --EXPECT--
Warning: socket_set_option(): No key "sec" passed in optval in %s on line %d socket_set_option(): Argument #4 ($optval) must have key "sec"
bool(true) bool(true)
bool(true) bool(true)
--CREDITS-- --CREDITS--

View file

@ -50,10 +50,10 @@ bool(true)
bool(true) 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 in %s on line %d
bool(false) 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 in %s on line %d
bool(false) bool(false)

View file

@ -51,8 +51,8 @@ bool(true)
bool(true) 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) 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) bool(false)