Lines Matching refs:php_sock
398 php_socket *php_sock = emalloc(sizeof(php_socket)); in php_create_socket() local
400 php_sock->bsd_socket = -1; /* invalid socket */ in php_create_socket()
401 php_sock->type = PF_UNSPEC; in php_create_socket()
402 php_sock->error = 0; in php_create_socket()
403 php_sock->blocking = 1; in php_create_socket()
404 ZVAL_UNDEF(&php_sock->zstream); in php_create_socket()
406 return php_sock; in php_create_socket()
412 php_socket *php_sock = rsrc->ptr; in php_destroy_socket() local
414 if (Z_ISUNDEF(php_sock->zstream)) { in php_destroy_socket()
415 if (!IS_INVALID_SOCKET(php_sock)) { in php_destroy_socket()
416 close(php_sock->bsd_socket); in php_destroy_socket()
419 zval_ptr_dtor(&php_sock->zstream); in php_destroy_socket()
421 efree(php_sock); in php_destroy_socket()
425 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog) /* {{{ */ argument
431 *php_sock = sock;
788 php_socket *php_sock; local
794 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
795 if (!php_sock) continue; /* If element is not a resource, skip it */
797 PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
798 if (php_sock->bsd_socket > *max_fd) {
799 *max_fd = php_sock->bsd_socket;
812 php_socket *php_sock; local
822 php_sock = (php_socket*) zend_fetch_resource_ex(element, le_socket_name, le_socket);
823 if (!php_sock) continue; /* If element is not a resource, skip it */
825 if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
926 php_socket *php_sock; local
933 if (!php_open_listen_sock(&php_sock, port, backlog)) {
937 php_sock->error = 0;
938 php_sock->blocking = 1;
940 RETURN_RES(zend_register_resource(php_sock, le_socket));
949 php_socket *php_sock, *new_sock; local
957 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
961 if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len)) {
974 php_socket *php_sock; local
980 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
984 if (!Z_ISUNDEF(php_sock->zstream)) {
987 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
991 php_sock->blocking = 0;
997 if (php_set_sock_blocking(php_sock->bsd_socket, 0) == SUCCESS) {
998 php_sock->blocking = 0;
1001 PHP_SOCKET_ERROR(php_sock, "unable to set nonblocking mode", errno);
1012 php_socket *php_sock; local
1018 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1025 if (!Z_ISUNDEF(php_sock->zstream)) {
1027 …stream = zend_fetch_resource2_ex(&php_sock->zstream, NULL, php_file_le_stream(), php_file_le_pstre…
1031 php_sock->blocking = 1;
1037 if (php_set_sock_blocking(php_sock->bsd_socket, 1) == SUCCESS) {
1038 php_sock->blocking = 1;
1041 PHP_SOCKET_ERROR(php_sock, "unable to set blocking mode", errno);
1052 php_socket *php_sock; local
1059 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1063 if (listen(php_sock->bsd_socket, backlog) != 0) {
1064 PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", 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…
1086 if (!Z_ISUNDEF(php_sock->zstream)) {
1088 php_stream_from_zval_no_verify(stream, &php_sock->zstream);
1106 php_socket *php_sock; local
1116 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1125 retval = write(php_sock->bsd_socket, str, MIN(length, str_len));
1127 retval = send(php_sock->bsd_socket, str, min(length, str_len), 0);
1131 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1144 php_socket *php_sock; local
1160 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1165 retval = php_read(php_sock, ZSTR_VAL(tmpbuf), length, 0);
1167 retval = recv(php_sock->bsd_socket, ZSTR_VAL(tmpbuf), length, 0);
1178 php_sock->error = errno;
1181 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1205 php_socket *php_sock; local
1220 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1226 if (getsockname(php_sock->bsd_socket, sa, &salen) != 0) {
1227 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket name", errno);
1288 php_socket *php_sock; local
1303 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1309 if (getpeername(php_sock->bsd_socket, sa, &salen) < 0) {
1310 PHP_SOCKET_ERROR(php_sock, "unable to retrieve peer name", errno);
1368 php_socket *php_sock = php_create_socket(); local
1371 efree(php_sock);
1389 php_sock->bsd_socket = socket(arg1, arg2, arg3);
1390 php_sock->type = arg1;
1392 if (IS_INVALID_SOCKET(php_sock)) {
1395 efree(php_sock);
1399 php_sock->error = 0;
1400 php_sock->blocking = 1;
1402 RETURN_RES(zend_register_resource(php_sock, le_socket));
1411 php_socket *php_sock; local
1422 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1426 switch(php_sock->type) {
1441 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1445 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin6, sizeof(struct sockaddr_in6));
1460 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1464 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
1478 retval = connect(php_sock->bsd_socket, (struct sockaddr *) &s_un,
1484 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1489 PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
1518 php_socket *php_sock; local
1528 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1532 switch(php_sock->type) {
1547 retval = bind(php_sock->bsd_socket, (struct sockaddr *) sa,
1559 if (! php_set_inet_addr(sa, addr, php_sock)) {
1563 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
1574 if (! php_set_inet6_addr(sa, addr, php_sock)) {
1578 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in6));
1583 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
1588 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
1602 php_socket *php_sock; local
1610 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(php_sock_res), le_socket_name, le_socket…
1621 if ((retval = recv(php_sock->bsd_socket, ZSTR_VAL(recv_buf), len, flags)) < 1) {
1636 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1649 php_socket *php_sock; local
1658 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1662 retval = send(php_sock->bsd_socket, buf, (buf_len < len ? buf_len : len), flags);
1665 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1678 php_socket *php_sock; local
1695 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1706 switch (php_sock->type) {
1710 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&s_un, …
1713 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1737 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin, (…
1740 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1768 …retval = recvfrom(php_sock->bsd_socket, ZSTR_VAL(recv_buf), arg3, arg4, (struct sockaddr *)&sin6, …
1771 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1791 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1804 php_socket *php_sock; local
1820 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1824 switch (php_sock->type) {
1830 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1842 if (! php_set_inet_addr(&sin, addr, php_sock)) {
1846 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1858 if (! php_set_inet6_addr(&sin6, addr, php_sock)) {
1862 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1866 php_error_docref(NULL, E_WARNING, "Unsupported socket type %d", php_sock->type);
1871 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1890 php_socket *php_sock; local
1898 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
1908 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
1909 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1912 if (php_add4_to_if_index(&if_addr, php_sock, &if_index) == SUCCESS) {
1922 int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value);
1936 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
1937 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1951 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
1952 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1958 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
1959 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1976 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
1977 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1995 php_socket *php_sock; local
2013 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2028 int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4);
2034 int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4);
2036 res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4);
2124 retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
2126 PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
2140 php_socket *php_sock[2]; local
2148 php_sock[0] = php_create_socket();
2149 php_sock[1] = php_create_socket();
2168 efree(php_sock[0]);
2169 efree(php_sock[1]);
2176 php_sock[0]->bsd_socket = fds_array[0];
2177 php_sock[1]->bsd_socket = fds_array[1];
2178 php_sock[0]->type = domain;
2179 php_sock[1]->type = domain;
2180 php_sock[0]->error = 0;
2181 php_sock[1]->error = 0;
2182 php_sock[0]->blocking = 1;
2183 php_sock[1]->blocking = 1;
2185 ZVAL_RES(&retval[0], zend_register_resource(php_sock[0], le_socket));
2186 ZVAL_RES(&retval[1], zend_register_resource(php_sock[1], le_socket));
2203 php_socket *php_sock; local
2209 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2213 if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
2214 PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
2228 php_socket *php_sock; local
2235 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2238 RETVAL_LONG(php_sock->error);
2250 php_socket *php_sock; local
2257 …if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(arg1), le_socket_name, le_socket)) == NU…
2260 php_sock->error = 0;