Lines Matching refs:php_sock
389 php_socket *php_sock = emalloc(sizeof *php_sock); in php_create_socket() local
391 php_sock->bsd_socket = -1; /* invalid socket */ in php_create_socket()
392 php_sock->type = PF_UNSPEC; in php_create_socket()
393 php_sock->error = 0; in php_create_socket()
394 php_sock->blocking = 1; in php_create_socket()
395 php_sock->zstream = NULL; in php_create_socket()
397 return php_sock; in php_create_socket()
403 php_socket *php_sock = rsrc->ptr; in php_destroy_socket() local
405 if (php_sock->zstream == NULL) { in php_destroy_socket()
406 if (!IS_INVALID_SOCKET(php_sock)) { in php_destroy_socket()
407 close(php_sock->bsd_socket); in php_destroy_socket()
410 zval_ptr_dtor(&php_sock->zstream); in php_destroy_socket()
412 efree(php_sock); in php_destroy_socket()
416 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC) /* {{{ */ argument
422 *php_sock = sock;
769 php_socket *php_sock; local
778 …php_sock = (php_socket*) zend_fetch_resource(element TSRMLS_CC, -1, le_socket_name, NULL, 1, le_so…
779 if (!php_sock) continue; /* If element is not a resource, skip it */
781 PHP_SAFE_FD_SET(php_sock->bsd_socket, fds);
782 if (php_sock->bsd_socket > *max_fd) {
783 *max_fd = php_sock->bsd_socket;
796 php_socket *php_sock; local
811 …php_sock = (php_socket*) zend_fetch_resource(element TSRMLS_CC, -1, le_socket_name, NULL, 1, le_so…
812 if (!php_sock) continue; /* If element is not a resource, skip it */
814 if (PHP_SAFE_FD_ISSET(php_sock->bsd_socket, fds)) {
918 php_socket *php_sock; local
925 if (!php_open_listen_sock(&php_sock, port, backlog TSRMLS_CC)) {
929 php_sock->error = 0;
930 php_sock->blocking = 1;
932 ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
941 php_socket *php_sock, *new_sock; local
949 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
951 if (!php_accept_connect(php_sock, &new_sock, (struct sockaddr*)&sa, &php_sa_len TSRMLS_CC)) {
964 php_socket *php_sock; local
970 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
972 if (php_sock->zstream != NULL) {
975 stream = zend_fetch_resource(&php_sock->zstream TSRMLS_CC, -1,
980 php_sock->blocking = 0;
986 if (php_set_sock_blocking(php_sock->bsd_socket, 0 TSRMLS_CC) == SUCCESS) {
987 php_sock->blocking = 0;
990 PHP_SOCKET_ERROR(php_sock, "unable to set nonblocking mode", errno);
1001 php_socket *php_sock; local
1007 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1012 if (php_sock->zstream != NULL) {
1014 stream = zend_fetch_resource(&php_sock->zstream TSRMLS_CC, -1,
1019 php_sock->blocking = 1;
1025 if (php_set_sock_blocking(php_sock->bsd_socket, 1 TSRMLS_CC) == SUCCESS) {
1026 php_sock->blocking = 1;
1029 PHP_SOCKET_ERROR(php_sock, "unable to set blocking mode", errno);
1040 php_socket *php_sock; local
1047 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1049 if (listen(php_sock->bsd_socket, backlog) != 0) {
1050 PHP_SOCKET_ERROR(php_sock, "unable to listen on socket", errno);
1062 php_socket *php_sock; local
1068 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1069 if (php_sock->zstream != NULL) {
1071 php_stream_from_zval_no_verify(stream, &php_sock->zstream);
1088 php_socket *php_sock; local
1097 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1104 retval = write(php_sock->bsd_socket, str, MIN(length, str_len));
1106 retval = send(php_sock->bsd_socket, str, min(length, str_len), 0);
1110 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1123 php_socket *php_sock; local
1139 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1142 retval = php_read(php_sock, tmpbuf, length, 0);
1144 retval = recv(php_sock->bsd_socket, tmpbuf, length, 0);
1155 php_sock->error = errno;
1158 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1181 php_socket *php_sock; local
1196 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1200 if (getsockname(php_sock->bsd_socket, sa, &salen) != 0) {
1201 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket name", errno);
1258 php_socket *php_sock; local
1273 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1277 if (getpeername(php_sock->bsd_socket, sa, &salen) < 0) {
1278 PHP_SOCKET_ERROR(php_sock, "unable to retrieve peer name", errno);
1336 php_socket *php_sock = php_create_socket(); local
1339 efree(php_sock);
1357 php_sock->bsd_socket = socket(arg1, arg2, arg3);
1358 php_sock->type = arg1;
1360 if (IS_INVALID_SOCKET(php_sock)) {
1363 efree(php_sock);
1367 php_sock->error = 0;
1368 php_sock->blocking = 1;
1370 ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket);
1379 php_socket *php_sock; local
1389 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1391 switch(php_sock->type) {
1406 if (! php_set_inet6_addr(&sin6, addr, php_sock TSRMLS_CC)) {
1410 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin6, sizeof(struct sockaddr_in6));
1425 if (! php_set_inet_addr(&sin, addr, php_sock TSRMLS_CC)) {
1429 retval = connect(php_sock->bsd_socket, (struct sockaddr *)&sin, sizeof(struct sockaddr_in));
1443 retval = connect(php_sock->bsd_socket, (struct sockaddr *) &s_un,
1449 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported socket type %d", php_sock->type);
1454 PHP_SOCKET_ERROR(php_sock, "unable to connect", errno);
1483 php_socket *php_sock; local
1493 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1495 switch(php_sock->type) {
1510 retval = bind(php_sock->bsd_socket, (struct sockaddr *) sa,
1522 if (! php_set_inet_addr(sa, addr, php_sock TSRMLS_CC)) {
1526 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
1537 if (! php_set_inet6_addr(sa, addr, php_sock TSRMLS_CC)) {
1541 retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in6));
1546 … E_WARNING, "unsupported socket type '%d', must be AF_UNIX, AF_INET, or AF_INET6", php_sock->type);
1551 PHP_SOCKET_ERROR(php_sock, "unable to bind address", errno);
1565 php_socket *php_sock; local
1573 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &php_sock_res, -1, le_socket_name, le_socket);
1583 if ((retval = recv(php_sock->bsd_socket, recv_buf, len, flags)) < 1) {
1600 PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
1613 php_socket *php_sock; local
1622 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1624 retval = send(php_sock->bsd_socket, buf, (buf_len < len ? buf_len : len), flags);
1627 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1640 php_socket *php_sock; local
1656 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1666 switch (php_sock->type) {
1670 …retval = recvfrom(php_sock->bsd_socket, recv_buf, arg3, arg4, (struct sockaddr *)&s_un, (socklen_t…
1673 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1695 …retval = recvfrom(php_sock->bsd_socket, recv_buf, arg3, arg4, (struct sockaddr *)&sin, (socklen_t …
1698 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1724 …retval = recvfrom(php_sock->bsd_socket, recv_buf, arg3, arg4, (struct sockaddr *)&sin6, (socklen_t…
1727 PHP_SOCKET_ERROR(php_sock, "unable to recvfrom", errno);
1745 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported socket type %d", php_sock->type);
1758 php_socket *php_sock; local
1773 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1775 switch (php_sock->type) {
1781 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1793 if (! php_set_inet_addr(&sin, addr, php_sock TSRMLS_CC)) {
1797 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1809 if (! php_set_inet6_addr(&sin6, addr, php_sock TSRMLS_CC)) {
1813 …retval = sendto(php_sock->bsd_socket, buf, (len > buf_len) ? buf_len : len, flags, (struct sockadd…
1817 php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unsupported socket type %d", php_sock->type);
1822 PHP_SOCKET_ERROR(php_sock, "unable to write to socket", errno);
1841 php_socket *php_sock; local
1849 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1857 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&if_addr, &optlen) != 0) {
1858 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1861 if (php_add4_to_if_index(&if_addr, php_sock, &if_index TSRMLS_CC) == SUCCESS) {
1871 int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value TSRMLS_CC);
1885 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&linger_val, &optlen) != 0) {
1886 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1900 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&tv, &optlen) != 0) {
1901 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1907 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&timeout, &optlen) != 0) {
1908 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1925 if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
1926 PHP_SOCKET_ERROR(php_sock, "unable to retrieve socket option", errno);
1944 php_socket *php_sock; local
1962 ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, le_socket);
1975 int res = php_do_setsockopt_ip_mcast(php_sock, level, optname, arg4 TSRMLS_CC);
1981 int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4 TSRMLS_CC);
1983 res = php_do_setsockopt_ipv6_rfc3542(php_sock, level, optname, arg4 TSRMLS_CC);
2071 retval = setsockopt(php_sock->bsd_socket, level, optname, opt_ptr, optlen);
2073 PHP_SOCKET_ERROR(php_sock, "unable to set socket option", errno);
2087 php_socket *php_sock[2]; local
2095 php_sock[0] = php_create_socket();
2096 php_sock[1] = php_create_socket();
2115 efree(php_sock[0]);
2116 efree(php_sock[1]);
2126 php_sock[0]->bsd_socket = fds_array[0];
2127 php_sock[1]->bsd_socket = fds_array[1];
2128 php_sock[0]->type = domain;
2129 php_sock[1]->type = domain;
2130 php_sock[0]->error = 0;
2131 php_sock[1]->error = 0;
2132 php_sock[0]->blocking = 1;
2133 php_sock[1]->blocking = 1;
2135 ZEND_REGISTER_RESOURCE(retval[0], php_sock[0], le_socket);
2136 ZEND_REGISTER_RESOURCE(retval[1], php_sock[1], le_socket);
2153 php_socket *php_sock; local
2159 ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, le_socket);
2161 if (shutdown(php_sock->bsd_socket, how_shutdown) != 0) {
2162 PHP_SOCKET_ERROR(php_sock, "unable to shutdown socket", errno);
2176 php_socket *php_sock; local
2183 ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, le_socket);
2184 RETVAL_LONG(php_sock->error);
2196 php_socket *php_sock; local
2203 ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, le_socket);
2204 php_sock->error = 0;