Lines Matching refs:php_sock

428 	php_socket *php_sock = emalloc(sizeof(php_socket));  in php_create_socket()  local
430 php_sock->bsd_socket = -1; /* invalid socket */ in php_create_socket()
431 php_sock->type = PF_UNSPEC; in php_create_socket()
432 php_sock->error = 0; in php_create_socket()
433 php_sock->blocking = 1; in php_create_socket()
434 ZVAL_UNDEF(&php_sock->zstream); in php_create_socket()
436 return php_sock; in php_create_socket()
442 php_socket *php_sock = rsrc->ptr; in php_destroy_socket() local
444 if (Z_ISUNDEF(php_sock->zstream)) { in php_destroy_socket()
445 if (!IS_INVALID_SOCKET(php_sock)) { in php_destroy_socket()
446 close(php_sock->bsd_socket); in php_destroy_socket()
449 zval_ptr_dtor(&php_sock->zstream); in php_destroy_socket()
451 efree(php_sock); in php_destroy_socket()
466 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog) /* {{{ */ argument
472 *php_sock = sock;
850 php_socket *php_sock; local
857 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
858 if (!php_sock) continue; /* If element is not a resource, skip it */
860 PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
861 if (php_sock->bsd_socket > *max_fd) {
862 *max_fd = php_sock->bsd_socket;
875 php_socket *php_sock; local
886 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
887 if (!php_sock) continue; /* If element is not a resource, skip it */
889 if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
990 php_socket *php_sock; local
997 if (!php_open_listen_sock(&php_sock, port, backlog)) {
1001 php_sock->error = 0;
1002 php_sock->blocking = 1;
1004 RETURN_RES(zend_register_resource(php_sock, le_socket));
1013 php_socket *php_sock, *new_sock; local
1021 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1025 if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
1038 php_socket *php_sock; local
1044 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1048 if (!Z_ISUNDEF(php_sock->zstream)) {
1051 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1055 php_sock->blocking = 0;
1061 if (php_set_sock_blocking(php_sock->bsd_socket, 0) == SUCCESS) {
1062 php_sock->blocking = 0;
1065 PHP_SOCKET_ERROR(php_sock, "unable to set nonblocking mode", errno);
1076 php_socket *php_sock; local
1082 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1089 if (!Z_ISUNDEF(php_sock->zstream)) {
1091 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1095 php_sock->blocking = 1;
1101 if (php_set_sock_blocking(php_sock->bsd_socket, 1) == SUCCESS) {
1102 php_sock->blocking = 1;
1105 PHP_SOCKET_ERROR(php_sock, "unable to set blocking mode", errno);
1116 php_socket *php_sock; local
1123 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1127 if (listen(php_sock->bsd_socket, backlog) != 0) {
1128 PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
1140 php_socket *php_sock; local
1146 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1150 if (!Z_ISUNDEF(php_sock->zstream)) {
1152 php_stream_from_zval_no_verify(stream, &php_sock->zstream);
1170 php_socket *php_sock; local
1185 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1194 retval = write(php_sock->bsd_socket, str, MIN(length, str_len));
1196 retval = send(php_sock->bsd_socket, str, min(length, str_len), 0);
1200 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1213 php_socket *php_sock; local
1229 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1234 retval = php_read(php_sock, ZSTR_VAL(tmpbuf), length, 0);
1236 retval = recv(php_sock->bsd_socket, ZSTR_VAL(tmpbuf), length, 0);
1247 php_sock->error = errno;
1250 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1274 php_socket *php_sock; local
1289 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1295 if (getsockname(php_sock->bsd_socket, sa, &salen) != 0) {
1296 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket name", errno);
1357 php_socket *php_sock; local
1372 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1378 if (getpeername(php_sock->bsd_socket, sa, &salen) < 0) {
1379 PHP_SOCKET_ERROR(php_sock, "unable to retrieve peer name", errno);
1437 php_socket *php_sock = php_create_socket(); local
1440 efree(php_sock);
1458 php_sock->bsd_socket = socket(arg1, arg2, arg3);
1459 php_sock->type = arg1;
1461 if (IS_INVALID_SOCKET(php_sock)) {
1464 efree(php_sock);
1468 php_sock->error = 0;
1469 php_sock->blocking = 1;
1471 RETURN_RES(zend_register_resource(php_sock, le_socket));
1480 php_socket *php_sock; local
1491 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1495 switch(php_sock->type) {
1510 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1514 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin6, sizeof(struct sockaddr_in6));
1529 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1533 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
1547 retval = connect(php_sock->bsd_socket, (struct sockaddr *) &s_un,
1553 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1558 PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
1587 php_socket *php_sock; local
1597 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1601 switch(php_sock->type) {
1616 retval = bind(php_sock->bsd_socket, (struct sockaddr *) sa,
1628 if (! php_set_inet_addr(sa, addr, php_sock)) {
1632 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
1643 if (! php_set_inet6_addr(sa, addr, php_sock)) {
1647 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in6));
1652 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
1657 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
1671 php_socket *php_sock; local
1679 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket…
1690 if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) {
1705 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1718 php_socket *php_sock; local
1732 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1736 retval = send(php_sock->bsd_socket, buf, (buf_len < (size_t)len ? buf_len : (size_t)len), flags);
1739 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1752 php_socket *php_sock; local
1769 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1780 switch (php_sock->type) {
1786 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, …
1789 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1813 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (…
1816 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1844 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, …
1847 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1867 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1880 php_socket *php_sock; local
1901 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1905 switch (php_sock->type) {
1911 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1923 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1927 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1939 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1943 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1947 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1952 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1971 php_socket *php_sock; local
1979 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1989 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
1990 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1993 if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) {
2003 int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value);
2017 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
2018 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2032 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
2033 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2039 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
2040 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2057 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
2058 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2076 php_socket *php_sock; local
2094 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2109 int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4);
2115 int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4);
2117 res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4);
2205 retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
2207 PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
2221 php_socket *php_sock[2]; local
2229 php_sock[0] = php_create_socket();
2230 php_sock[1] = php_create_socket();
2249 efree(php_sock[0]);
2250 efree(php_sock[1]);
2257 php_sock[0]->bsd_socket = fds_array[0];
2258 php_sock[1]->bsd_socket = fds_array[1];
2259 php_sock[0]->type = domain;
2260 php_sock[1]->type = domain;
2261 php_sock[0]->error = 0;
2262 php_sock[1]->error = 0;
2263 php_sock[0]->blocking = 1;
2264 php_sock[1]->blocking = 1;
2266 ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
2267 ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
2284 php_socket *php_sock; local
2290 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2294 if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
2295 PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
2309 php_socket *php_sock; local
2316 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2319 RETVAL_LONG(php_sock->error);
2331 php_socket *php_sock; local
2338 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2341 php_sock->error = 0;
2608 php_socket *php_sock; local
2618 php_sock = php_create_socket();
2619 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2620 php_sock->type = ai->ai_family;
2622 if (IS_INVALID_SOCKET(php_sock)) {
2625 efree(php_sock);
2629 php_sock->error = 0;
2630 php_sock->blocking = 1;
2632 switch(php_sock->type) {
2636 close(php_sock->bsd_socket);
2637 efree(php_sock);
2646 retval = bind(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2650 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2651 close(php_sock->bsd_socket);
2652 efree(php_sock);
2657 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
2658 close(php_sock->bsd_socket);
2659 efree(php_sock);
2663 RETURN_RES(zend_register_resource(php_sock, le_socket));
2674 php_socket *php_sock; local
2684 php_sock = php_create_socket();
2685 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2686 php_sock->type = ai->ai_family;
2688 if (IS_INVALID_SOCKET(php_sock)) {
2691 efree(php_sock);
2695 php_sock->error = 0;
2696 php_sock->blocking = 1;
2698 switch(php_sock->type) {
2702 close(php_sock->bsd_socket);
2703 efree(php_sock);
2712 retval = connect(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2716 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2717 close(php_sock->bsd_socket);
2718 efree(php_sock);
2723 PHP_SOCKET_ERROR(php_sock, "unable to connect address", errno);
2724 close(php_sock->bsd_socket);
2725 efree(php_sock);
2729 RETURN_RES(zend_register_resource(php_sock, le_socket));