Lines Matching refs:php_sock

461 	php_socket *php_sock = emalloc(sizeof(php_socket));  in php_create_socket()  local
463 php_sock->bsd_socket = -1; /* invalid socket */ in php_create_socket()
464 php_sock->type = PF_UNSPEC; in php_create_socket()
465 php_sock->error = 0; in php_create_socket()
466 php_sock->blocking = 1; in php_create_socket()
467 ZVAL_UNDEF(&php_sock->zstream); in php_create_socket()
469 return php_sock; in php_create_socket()
475 php_socket *php_sock = rsrc->ptr; in php_destroy_socket() local
477 if (Z_ISUNDEF(php_sock->zstream)) { in php_destroy_socket()
478 if (!IS_INVALID_SOCKET(php_sock)) { in php_destroy_socket()
479 close(php_sock->bsd_socket); in php_destroy_socket()
482 zval_ptr_dtor(&php_sock->zstream); in php_destroy_socket()
484 efree(php_sock); in php_destroy_socket()
499 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog) /* {{{ */ argument
505 *php_sock = sock;
909 php_socket *php_sock; local
916 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
917 if (!php_sock) continue; /* If element is not a resource, skip it */
919 PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
920 if (php_sock->bsd_socket > *max_fd) {
921 *max_fd = php_sock->bsd_socket;
934 php_socket *php_sock; local
945 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
946 if (!php_sock) continue; /* If element is not a resource, skip it */
948 if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
1038 php_socket *php_sock; local
1045 if (!php_open_listen_sock(&php_sock, port, backlog)) {
1049 php_sock->error = 0;
1050 php_sock->blocking = 1;
1052 RETURN_RES(zend_register_resource(php_sock, le_socket));
1061 php_socket *php_sock, *new_sock; local
1069 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1073 if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
1086 php_socket *php_sock; local
1092 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1096 if (!Z_ISUNDEF(php_sock->zstream)) {
1099 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1103 php_sock->blocking = 0;
1109 if (php_set_sock_blocking(php_sock->bsd_socket, 0) == SUCCESS) {
1110 php_sock->blocking = 0;
1113 PHP_SOCKET_ERROR(php_sock, "unable to set nonblocking mode", errno);
1124 php_socket *php_sock; local
1130 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1137 if (!Z_ISUNDEF(php_sock->zstream)) {
1139 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1143 php_sock->blocking = 1;
1149 if (php_set_sock_blocking(php_sock->bsd_socket, 1) == SUCCESS) {
1150 php_sock->blocking = 1;
1153 PHP_SOCKET_ERROR(php_sock, "unable to set blocking mode", errno);
1164 php_socket *php_sock; local
1171 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1175 if (listen(php_sock->bsd_socket, backlog) != 0) {
1176 PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
1188 php_socket *php_sock; local
1194 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1198 if (!Z_ISUNDEF(php_sock->zstream)) {
1200 php_stream_from_zval_no_verify(stream, &php_sock->zstream);
1218 php_socket *php_sock; local
1233 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1242 retval = write(php_sock->bsd_socket, str, MIN(length, str_len));
1244 retval = send(php_sock->bsd_socket, str, min(length, str_len), 0);
1248 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1261 php_socket *php_sock; local
1277 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1282 retval = php_read(php_sock, ZSTR_VAL(tmpbuf), length, 0);
1284 retval = recv(php_sock->bsd_socket, ZSTR_VAL(tmpbuf), length, 0);
1295 php_sock->error = errno;
1298 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1322 php_socket *php_sock; local
1337 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1343 if (getsockname(php_sock->bsd_socket, sa, &salen) != 0) {
1344 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket name", errno);
1396 php_socket *php_sock; local
1411 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1417 if (getpeername(php_sock->bsd_socket, sa, &salen) < 0) {
1418 PHP_SOCKET_ERROR(php_sock, "unable to retrieve peer name", errno);
1472 php_socket *php_sock = php_create_socket(); local
1475 efree(php_sock);
1493 php_sock->bsd_socket = socket(arg1, arg2, arg3);
1494 php_sock->type = arg1;
1496 if (IS_INVALID_SOCKET(php_sock)) {
1499 efree(php_sock);
1503 php_sock->error = 0;
1504 php_sock->blocking = 1;
1506 RETURN_RES(zend_register_resource(php_sock, le_socket));
1515 php_socket *php_sock; local
1526 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1530 switch(php_sock->type) {
1545 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1549 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin6, sizeof(struct sockaddr_in6));
1564 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1568 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
1582 retval = connect(php_sock->bsd_socket, (struct sockaddr *) &s_un,
1588 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1593 PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
1622 php_socket *php_sock; local
1632 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1636 switch(php_sock->type) {
1651 retval = bind(php_sock->bsd_socket, (struct sockaddr *) sa,
1663 if (! php_set_inet_addr(sa, addr, php_sock)) {
1667 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
1678 if (! php_set_inet6_addr(sa, addr, php_sock)) {
1682 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in6));
1687 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
1692 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
1706 php_socket *php_sock; local
1714 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket…
1725 if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) {
1735 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1748 php_socket *php_sock; local
1762 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1766 retval = send(php_sock->bsd_socket, buf, (buf_len < (size_t)len ? buf_len : (size_t)len), flags);
1769 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1782 php_socket *php_sock; local
1799 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1810 switch (php_sock->type) {
1816 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, …
1819 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1840 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (…
1843 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1867 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, …
1870 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1886 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1899 php_socket *php_sock; local
1920 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1924 switch (php_sock->type) {
1930 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1942 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1946 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1958 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1962 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1966 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1971 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1990 php_socket *php_sock; local
1998 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2008 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
2009 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2012 if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) {
2022 int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value);
2036 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
2037 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2051 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
2052 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2058 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
2059 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2077 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
2078 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2096 php_socket *php_sock; local
2114 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2129 int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4);
2135 int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4);
2137 res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4);
2225 retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
2227 PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
2241 php_socket *php_sock[2]; local
2249 php_sock[0] = php_create_socket();
2250 php_sock[1] = php_create_socket();
2269 efree(php_sock[0]);
2270 efree(php_sock[1]);
2276 efree(php_sock[0]);
2277 efree(php_sock[1]);
2281 php_sock[0]->bsd_socket = fds_array[0];
2282 php_sock[1]->bsd_socket = fds_array[1];
2283 php_sock[0]->type = domain;
2284 php_sock[1]->type = domain;
2285 php_sock[0]->error = 0;
2286 php_sock[1]->error = 0;
2287 php_sock[0]->blocking = 1;
2288 php_sock[1]->blocking = 1;
2290 ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
2291 ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
2308 php_socket *php_sock; local
2314 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2318 if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
2319 PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
2333 php_socket *php_sock; local
2340 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2343 RETVAL_LONG(php_sock->error);
2355 php_socket *php_sock; local
2362 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2365 php_sock->error = 0;
2639 php_socket *php_sock; local
2649 php_sock = php_create_socket();
2650 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2651 php_sock->type = ai->ai_family;
2653 if (IS_INVALID_SOCKET(php_sock)) {
2656 efree(php_sock);
2660 php_sock->error = 0;
2661 php_sock->blocking = 1;
2663 switch(php_sock->type) {
2667 close(php_sock->bsd_socket);
2668 efree(php_sock);
2677 retval = bind(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2681 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2682 close(php_sock->bsd_socket);
2683 efree(php_sock);
2688 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
2689 close(php_sock->bsd_socket);
2690 efree(php_sock);
2694 RETURN_RES(zend_register_resource(php_sock, le_socket));
2705 php_socket *php_sock; local
2715 php_sock = php_create_socket();
2716 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2717 php_sock->type = ai->ai_family;
2719 if (IS_INVALID_SOCKET(php_sock)) {
2722 efree(php_sock);
2726 php_sock->error = 0;
2727 php_sock->blocking = 1;
2729 switch(php_sock->type) {
2733 close(php_sock->bsd_socket);
2734 efree(php_sock);
2743 retval = connect(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2747 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2748 close(php_sock->bsd_socket);
2749 efree(php_sock);
2754 PHP_SOCKET_ERROR(php_sock, "unable to connect address", errno);
2755 close(php_sock->bsd_socket);
2756 efree(php_sock);
2760 RETURN_RES(zend_register_resource(php_sock, le_socket));
2885 php_socket *php_sock; local
2926 php_sock = php_create_socket();
2927 php_sock->bsd_socket = sock;
2928 php_sock->type = wi.iAddressFamily;
2929 php_sock->error = 0;
2930 php_sock->blocking = 1;
2932 RETURN_RES(zend_register_resource(php_sock, le_socket));