Lines Matching refs:sock

59 	php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;  in php_sockop_write()  local
63 if (!sock || sock->socket == -1) { in php_sockop_write()
67 if (sock->timeout.tv_sec == -1) in php_sockop_write()
70 ptimeout = &sock->timeout; in php_sockop_write()
73 …didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_D… in php_sockop_write()
80 if (sock->is_blocked) { in php_sockop_write()
83 sock->timeout_event = 0; in php_sockop_write()
86 retval = php_pollfd_for(sock->socket, POLLOUT, ptimeout); in php_sockop_write()
89 sock->timeout_event = 1; in php_sockop_write()
123 static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data_t *sock, bool has_… in php_sock_stream_wait_for_data() argument
128 if (!sock || sock->socket == -1) { in php_sock_stream_wait_for_data()
132 sock->timeout_event = 0; in php_sock_stream_wait_for_data()
139 } else if (sock->timeout.tv_sec == -1) { in php_sock_stream_wait_for_data()
142 ptimeout = &sock->timeout; in php_sock_stream_wait_for_data()
146 retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout); in php_sock_stream_wait_for_data()
149 sock->timeout_event = 1; in php_sock_stream_wait_for_data()
161 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_read() local
163 if (!sock || sock->socket == -1) { in php_sockop_read()
169 if (sock->is_blocked) { in php_sockop_read()
174 (sock->timeout.tv_sec == 0 && sock->timeout.tv_usec == 0); in php_sockop_read()
177 if (dont_wait || sock->timeout.tv_sec != -1) { in php_sockop_read()
183 php_sock_stream_wait_for_data(stream, sock, has_buffered_data); in php_sockop_read()
184 if (sock->timeout_event) { in php_sockop_read()
191 ssize_t nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), recv_flags); in php_sockop_read()
214 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_close() local
219 if (!sock) { in php_sockop_close()
226 if (sock->socket == -1) in php_sockop_close()
227 sock->socket = SOCK_ERR; in php_sockop_close()
229 if (sock->socket != SOCK_ERR) { in php_sockop_close()
232 shutdown(sock->socket, SHUT_RD); in php_sockop_close()
241 n = php_pollfd_for_ms(sock->socket, POLLOUT, 500); in php_sockop_close()
244 closesocket(sock->socket); in php_sockop_close()
245 sock->socket = SOCK_ERR; in php_sockop_close()
250 pefree(sock, php_stream_is_persistent(stream)); in php_sockop_close()
258 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_flush()
259 return fsync(sock->socket); in php_sockop_flush()
269 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_stat()
271 return zend_fstat(sock->socket, &ssb->sb); in php_sockop_stat()
275 static inline int sock_sendto(php_netstream_data_t *sock, const char *buf, size_t buflen, int flags, in sock_sendto() argument
281 ret = sendto(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, addr, XP_SOCK_BUF_SIZE(addrlen)); in sock_sendto()
286 …return ((ret = send(sock->socket, buf, buflen > INT_MAX ? INT_MAX : (int)buflen, flags)) == SOCK_C… in sock_sendto()
288 return ((ret = send(sock->socket, buf, buflen, flags)) == SOCK_CONN_ERR) ? -1 : ret; in sock_sendto()
292 static inline int sock_recvfrom(php_netstream_data_t *sock, char *buf, size_t buflen, int flags, in sock_recvfrom() argument
303 ret = recvfrom(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags, (struct sockaddr*)&sa, &sl); in sock_recvfrom()
324 ret = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(buflen), flags); in sock_recvfrom()
334 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_set_option() local
337 if (!sock) { in php_sockop_set_option()
349 if (sock->timeout.tv_sec == -1) { in php_sockop_set_option()
353 tv = sock->timeout; in php_sockop_set_option()
360 if (sock->socket == -1) { in php_sockop_set_option()
366 ((MSG_DONTWAIT != 0) || !sock->is_blocked) in php_sockop_set_option()
368 php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0 in php_sockop_set_option()
377 ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK|MSG_DONTWAIT); in php_sockop_set_option()
393 oldmode = sock->is_blocked; in php_sockop_set_option()
394 if (SUCCESS == php_set_sock_blocking(sock->socket, value)) { in php_sockop_set_option()
395 sock->is_blocked = value; in php_sockop_set_option()
401 sock->timeout = *(struct timeval*)ptrparam; in php_sockop_set_option()
402 sock->timeout_event = 0; in php_sockop_set_option()
406 add_assoc_bool((zval *)ptrparam, "timed_out", sock->timeout_event); in php_sockop_set_option()
407 add_assoc_bool((zval *)ptrparam, "blocked", sock->is_blocked); in php_sockop_set_option()
416 xparam->outputs.returncode = (listen(sock->socket, xparam->inputs.backlog) == 0) ? 0: -1; in php_sockop_set_option()
420 xparam->outputs.returncode = php_network_get_sock_name(sock->socket, in php_sockop_set_option()
428 xparam->outputs.returncode = php_network_get_peer_name(sock->socket, in php_sockop_set_option()
440 xparam->outputs.returncode = sock_sendto(sock, in php_sockop_set_option()
461 xparam->outputs.returncode = sock_recvfrom(sock, in php_sockop_set_option()
484 xparam->outputs.returncode = shutdown(sock->socket, shutdown_how[xparam->how]); in php_sockop_set_option()
499 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_sockop_cast() local
501 if (!sock) { in php_sockop_cast()
508 *(FILE**)ret = fdopen(sock->socket, stream->mode); in php_sockop_cast()
518 *(php_socket_t *)ret = sock->socket; in php_sockop_cast()
662 static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t *sock, in php_tcp_sockop_bind() argument
674sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGR… in php_tcp_sockop_bind()
676 if (sock->socket == SOCK_ERR) { in php_tcp_sockop_bind()
687 return bind(sock->socket, (const struct sockaddr *)&unix_addr, in php_tcp_sockop_bind()
727 sock->socket = php_network_bind_socket_to_local_addr(host, portno, in php_tcp_sockop_bind()
738 return sock->socket == -1 ? -1 : 0; in php_tcp_sockop_bind()
741 static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_t *sock, in php_tcp_sockop_connect() argument
755sock->socket = socket(PF_UNIX, stream->ops == &php_stream_unix_socket_ops ? SOCK_STREAM : SOCK_DGR… in php_tcp_sockop_connect()
757 if (sock->socket == SOCK_ERR) { in php_tcp_sockop_connect()
766 ret = php_network_connect_socket(sock->socket, in php_tcp_sockop_connect()
821 sock->socket = php_network_connect_socket_to_host(host, portno, in php_tcp_sockop_connect()
832 ret = sock->socket == -1 ? -1 : 0; in php_tcp_sockop_connect()
854 static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t *sock, in php_tcp_sockop_accept() argument
869 clisock = php_network_accept_incoming(sock->socket, in php_tcp_sockop_accept()
881 memcpy(clisockdata, sock, sizeof(*clisockdata)); in php_tcp_sockop_accept()
902 php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract; in php_tcp_sockop_set_option() local
912 xparam->outputs.returncode = php_tcp_sockop_connect(stream, sock, xparam); in php_tcp_sockop_set_option()
916 xparam->outputs.returncode = php_tcp_sockop_bind(stream, sock, xparam); in php_tcp_sockop_set_option()
921 xparam->outputs.returncode = php_tcp_sockop_accept(stream, sock, xparam STREAMS_CC); in php_tcp_sockop_set_option()
939 php_netstream_data_t *sock; in php_stream_generic_socket_factory() local
960 sock = pemalloc(sizeof(php_netstream_data_t), persistent_id ? 1 : 0); in php_stream_generic_socket_factory()
961 memset(sock, 0, sizeof(php_netstream_data_t)); in php_stream_generic_socket_factory()
963 sock->is_blocked = 1; in php_stream_generic_socket_factory()
964 sock->timeout.tv_sec = FG(default_socket_timeout); in php_stream_generic_socket_factory()
965 sock->timeout.tv_usec = 0; in php_stream_generic_socket_factory()
969 sock->socket = -1; in php_stream_generic_socket_factory()
971 stream = php_stream_alloc_rel(ops, sock, persistent_id, "r+"); in php_stream_generic_socket_factory()
974 pefree(sock, persistent_id ? 1 : 0); in php_stream_generic_socket_factory()