Lines Matching refs:php_sock
452 php_socket *php_sock = emalloc(sizeof(php_socket)); in php_create_socket() local
454 php_sock->bsd_socket = -1; /* invalid socket */ in php_create_socket()
455 php_sock->type = PF_UNSPEC; in php_create_socket()
456 php_sock->error = 0; in php_create_socket()
457 php_sock->blocking = 1; in php_create_socket()
458 ZVAL_UNDEF(&php_sock->zstream); in php_create_socket()
460 return php_sock; in php_create_socket()
466 php_socket *php_sock = rsrc->ptr; in php_destroy_socket() local
468 if (Z_ISUNDEF(php_sock->zstream)) { in php_destroy_socket()
469 if (!IS_INVALID_SOCKET(php_sock)) { in php_destroy_socket()
470 close(php_sock->bsd_socket); in php_destroy_socket()
473 zval_ptr_dtor(&php_sock->zstream); in php_destroy_socket()
475 efree(php_sock); in php_destroy_socket()
490 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog) /* {{{ */ argument
496 *php_sock = sock;
895 php_socket *php_sock; local
902 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
903 if (!php_sock) continue; /* If element is not a resource, skip it */
905 PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
906 if (php_sock->bsd_socket > *max_fd) {
907 *max_fd = php_sock->bsd_socket;
920 php_socket *php_sock; local
931 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
932 if (!php_sock) continue; /* If element is not a resource, skip it */
934 if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
1024 php_socket *php_sock; local
1031 if (!php_open_listen_sock(&php_sock, port, backlog)) {
1035 php_sock->error = 0;
1036 php_sock->blocking = 1;
1038 RETURN_RES(zend_register_resource(php_sock, le_socket));
1047 php_socket *php_sock, *new_sock; local
1055 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1059 if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
1072 php_socket *php_sock; local
1078 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1082 if (!Z_ISUNDEF(php_sock->zstream)) {
1085 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1089 php_sock->blocking = 0;
1095 if (php_set_sock_blocking(php_sock->bsd_socket, 0) == SUCCESS) {
1096 php_sock->blocking = 0;
1099 PHP_SOCKET_ERROR(php_sock, "unable to set nonblocking mode", errno);
1110 php_socket *php_sock; local
1116 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1123 if (!Z_ISUNDEF(php_sock->zstream)) {
1125 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1129 php_sock->blocking = 1;
1135 if (php_set_sock_blocking(php_sock->bsd_socket, 1) == SUCCESS) {
1136 php_sock->blocking = 1;
1139 PHP_SOCKET_ERROR(php_sock, "unable to set blocking mode", errno);
1150 php_socket *php_sock; local
1157 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1161 if (listen(php_sock->bsd_socket, backlog) != 0) {
1162 PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
1174 php_socket *php_sock; local
1180 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1184 if (!Z_ISUNDEF(php_sock->zstream)) {
1186 php_stream_from_zval_no_verify(stream, &php_sock->zstream);
1204 php_socket *php_sock; local
1219 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1228 retval = write(php_sock->bsd_socket, str, MIN(length, str_len));
1230 retval = send(php_sock->bsd_socket, str, min(length, str_len), 0);
1234 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1247 php_socket *php_sock; local
1263 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1268 retval = php_read(php_sock, ZSTR_VAL(tmpbuf), length, 0);
1270 retval = recv(php_sock->bsd_socket, ZSTR_VAL(tmpbuf), length, 0);
1281 php_sock->error = errno;
1284 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1308 php_socket *php_sock; local
1323 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1329 if (getsockname(php_sock->bsd_socket, sa, &salen) != 0) {
1330 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket name", errno);
1391 php_socket *php_sock; local
1406 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1412 if (getpeername(php_sock->bsd_socket, sa, &salen) < 0) {
1413 PHP_SOCKET_ERROR(php_sock, "unable to retrieve peer name", errno);
1471 php_socket *php_sock = php_create_socket(); local
1474 efree(php_sock);
1492 php_sock->bsd_socket = socket(arg1, arg2, arg3);
1493 php_sock->type = arg1;
1495 if (IS_INVALID_SOCKET(php_sock)) {
1498 efree(php_sock);
1502 php_sock->error = 0;
1503 php_sock->blocking = 1;
1505 RETURN_RES(zend_register_resource(php_sock, le_socket));
1514 php_socket *php_sock; local
1525 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1529 switch(php_sock->type) {
1544 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1548 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin6, sizeof(struct sockaddr_in6));
1563 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1567 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
1581 retval = connect(php_sock->bsd_socket, (struct sockaddr *) &s_un,
1587 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1592 PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
1621 php_socket *php_sock; local
1631 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1635 switch(php_sock->type) {
1650 retval = bind(php_sock->bsd_socket, (struct sockaddr *) sa,
1662 if (! php_set_inet_addr(sa, addr, php_sock)) {
1666 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
1677 if (! php_set_inet6_addr(sa, addr, php_sock)) {
1681 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in6));
1686 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
1691 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
1705 php_socket *php_sock; local
1713 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket…
1724 if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) {
1739 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1752 php_socket *php_sock; local
1766 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1770 retval = send(php_sock->bsd_socket, buf, (buf_len < (size_t)len ? buf_len : (size_t)len), flags);
1773 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1786 php_socket *php_sock; local
1803 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1814 switch (php_sock->type) {
1820 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, …
1823 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1847 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (…
1850 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1878 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, …
1881 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1901 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1914 php_socket *php_sock; local
1935 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1939 switch (php_sock->type) {
1945 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1957 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1961 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1973 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1977 …retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags,…
1981 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1986 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
2005 php_socket *php_sock; local
2013 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2023 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
2024 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2027 if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) {
2037 int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value);
2051 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
2052 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2066 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
2067 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2073 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
2074 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2091 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
2092 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
2110 php_socket *php_sock; local
2128 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2143 int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4);
2149 int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4);
2151 res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4);
2239 retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
2241 PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
2255 php_socket *php_sock[2]; local
2263 php_sock[0] = php_create_socket();
2264 php_sock[1] = php_create_socket();
2283 efree(php_sock[0]);
2284 efree(php_sock[1]);
2291 php_sock[0]->bsd_socket = fds_array[0];
2292 php_sock[1]->bsd_socket = fds_array[1];
2293 php_sock[0]->type = domain;
2294 php_sock[1]->type = domain;
2295 php_sock[0]->error = 0;
2296 php_sock[1]->error = 0;
2297 php_sock[0]->blocking = 1;
2298 php_sock[1]->blocking = 1;
2300 ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
2301 ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
2318 php_socket *php_sock; local
2324 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2328 if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
2329 PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
2343 php_socket *php_sock; local
2350 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2353 RETVAL_LONG(php_sock->error);
2365 php_socket *php_sock; local
2372 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2375 php_sock->error = 0;
2642 php_socket *php_sock; local
2652 php_sock = php_create_socket();
2653 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2654 php_sock->type = ai->ai_family;
2656 if (IS_INVALID_SOCKET(php_sock)) {
2659 efree(php_sock);
2663 php_sock->error = 0;
2664 php_sock->blocking = 1;
2666 switch(php_sock->type) {
2670 close(php_sock->bsd_socket);
2671 efree(php_sock);
2680 retval = bind(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2684 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2685 close(php_sock->bsd_socket);
2686 efree(php_sock);
2691 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
2692 close(php_sock->bsd_socket);
2693 efree(php_sock);
2697 RETURN_RES(zend_register_resource(php_sock, le_socket));
2708 php_socket *php_sock; local
2718 php_sock = php_create_socket();
2719 php_sock->bsd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
2720 php_sock->type = ai->ai_family;
2722 if (IS_INVALID_SOCKET(php_sock)) {
2725 efree(php_sock);
2729 php_sock->error = 0;
2730 php_sock->blocking = 1;
2732 switch(php_sock->type) {
2736 close(php_sock->bsd_socket);
2737 efree(php_sock);
2746 retval = connect(php_sock->bsd_socket, ai->ai_addr, ai->ai_addrlen);
2750 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
2751 close(php_sock->bsd_socket);
2752 efree(php_sock);
2757 PHP_SOCKET_ERROR(php_sock, "unable to connect address", errno);
2758 close(php_sock->bsd_socket);
2759 efree(php_sock);
2763 RETURN_RES(zend_register_resource(php_sock, le_socket));
2894 php_socket *php_sock; local
2941 php_sock = php_create_socket();
2942 php_sock->bsd_socket = sock;
2943 php_sock->type = wi.iAddressFamily;
2944 php_sock->error = 0;
2945 php_sock->blocking = 1;
2947 RETURN_RES(zend_register_resource(php_sock, le_socket));