mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Convert resources to objects in ext/sockets
Closes GH-5900.
This commit is contained in:
parent
e0fa48f69d
commit
77172c220a
36 changed files with 624 additions and 537 deletions
|
@ -20,7 +20,7 @@ PHP Testfest Berlin 2009-05-10
|
|||
<?php
|
||||
var_dump(posix_ttyname(0)); // param not a resource
|
||||
try {
|
||||
var_dump(posix_ttyname(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP))); // wrong resource type
|
||||
var_dump(posix_ttyname(finfo_open(FILEINFO_NONE, __DIR__))); // wrong resource type
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
|
|
@ -1341,29 +1341,32 @@ static void from_zval_write_fd_array_aux(zval *elem, unsigned i, void **args, se
|
|||
{
|
||||
int *iarr = args[0];
|
||||
|
||||
if (Z_TYPE_P(elem) == IS_RESOURCE) {
|
||||
php_stream *stream;
|
||||
php_socket *sock;
|
||||
|
||||
sock = (php_socket *)zend_fetch_resource_ex(elem, NULL, php_sockets_le_socket());
|
||||
if (sock) {
|
||||
iarr[i] = sock->bsd_socket;
|
||||
if (Z_TYPE_P(elem) == IS_OBJECT && Z_OBJCE_P(elem) == socket_ce) {
|
||||
php_socket *sock = Z_SOCKET_P(elem);
|
||||
if (IS_INVALID_SOCKET(sock)) {
|
||||
do_from_zval_err(ctx, "socket is already closed");
|
||||
return;
|
||||
}
|
||||
|
||||
iarr[i] = sock->bsd_socket;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Z_TYPE_P(elem) == IS_RESOURCE) {
|
||||
php_stream *stream;
|
||||
|
||||
stream = (php_stream *)zend_fetch_resource2_ex(elem, NULL, php_file_le_stream(), php_file_le_pstream());
|
||||
if (stream == NULL) {
|
||||
do_from_zval_err(ctx, "resource is not a stream or a socket");
|
||||
do_from_zval_err(ctx, "resource is not a stream");
|
||||
return;
|
||||
}
|
||||
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&iarr[i - 1],
|
||||
REPORT_ERRORS) == FAILURE) {
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void **)&iarr[i - 1], REPORT_ERRORS) == FAILURE) {
|
||||
do_from_zval_err(ctx, "cast stream to file descriptor failed");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
do_from_zval_err(ctx, "expected a resource variable");
|
||||
do_from_zval_err(ctx, "expected a Socket object or a stream resource");
|
||||
}
|
||||
}
|
||||
void from_zval_write_fd_array(const zval *arr, char *int_arr, ser_context *ctx)
|
||||
|
@ -1414,8 +1417,10 @@ void to_zval_read_fd_array(const char *data, zval *zv, res_context *ctx)
|
|||
return;
|
||||
}
|
||||
if (S_ISSOCK(statbuf.st_mode)) {
|
||||
php_socket *sock = socket_import_file_descriptor(fd);
|
||||
ZVAL_RES(&elem, zend_register_resource(sock, php_sockets_le_socket()));
|
||||
object_init_ex(&elem, socket_ce);
|
||||
php_socket *sock = Z_SOCKET_P(&elem);
|
||||
|
||||
socket_import_file_descriptor(fd, sock);
|
||||
} else {
|
||||
php_stream *stream = php_stream_fopen_from_fd(fd, "rw", NULL);
|
||||
php_stream_to_zval(stream, &elem);
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <php.h>
|
||||
#ifdef PHP_WIN32
|
||||
# include "windows_common.h"
|
||||
#else
|
||||
# define IS_INVALID_SOCKET(a) (a->bsd_socket < 0)
|
||||
#endif
|
||||
|
||||
#define PHP_SOCKETS_VERSION PHP_VERSION
|
||||
|
@ -52,14 +54,32 @@ typedef int PHP_SOCKET;
|
|||
typedef SOCKET PHP_SOCKET;
|
||||
#endif
|
||||
|
||||
/* Socket class */
|
||||
|
||||
typedef struct {
|
||||
PHP_SOCKET bsd_socket;
|
||||
int type;
|
||||
int error;
|
||||
int blocking;
|
||||
zval zstream;
|
||||
zend_object std;
|
||||
} php_socket;
|
||||
|
||||
extern zend_class_entry *socket_ce;
|
||||
|
||||
static inline php_socket *socket_from_obj(zend_object *obj) {
|
||||
return (php_socket *)((char *)(obj) - XtOffsetOf(php_socket, std));
|
||||
}
|
||||
|
||||
#define Z_SOCKET_P(zv) socket_from_obj(Z_OBJ_P(zv))
|
||||
|
||||
#define ENSURE_SOCKET_VALID(php_sock) do { \
|
||||
if (IS_INVALID_SOCKET(php_sock)) { \
|
||||
zend_argument_error(NULL, 1, "has already been closed"); \
|
||||
RETURN_THROWS(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
struct sockaddr_un {
|
||||
short sun_family;
|
||||
|
@ -67,14 +87,6 @@ struct sockaddr_un {
|
|||
};
|
||||
#endif
|
||||
|
||||
PHP_SOCKETS_API int php_sockets_le_socket(void);
|
||||
PHP_SOCKETS_API php_socket *php_create_socket(void);
|
||||
PHP_SOCKETS_API void php_destroy_socket(zend_resource *rsrc);
|
||||
PHP_SOCKETS_API void php_destroy_sockaddr(zend_resource *rsrc);
|
||||
|
||||
#define php_sockets_le_socket_name "Socket"
|
||||
#define php_sockets_le_addrinfo_name "AddressInfo"
|
||||
|
||||
#define PHP_SOCKET_ERROR(socket, msg, errn) \
|
||||
do { \
|
||||
int _err = (errn); /* save value to avoid repeated calls to WSAGetLastError() on Windows */ \
|
||||
|
@ -104,7 +116,7 @@ enum sockopt_return {
|
|||
};
|
||||
|
||||
char *sockets_strerror(int error);
|
||||
php_socket *socket_import_file_descriptor(PHP_SOCKET sock);
|
||||
int socket_import_file_descriptor(PHP_SOCKET socket, php_socket *retsock);
|
||||
|
||||
#else
|
||||
#define phpext_sockets_ptr NULL
|
||||
|
|
|
@ -172,16 +172,14 @@ PHP_FUNCTION(socket_sendmsg)
|
|||
ssize_t res;
|
||||
|
||||
/* zmsg should be passed by ref */
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra|l", &zsocket, &zmsg, &flags) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa|l", &zsocket, socket_ce, &zmsg, &flags) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
LONG_CHECK_VALID_INT(flags, 3);
|
||||
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
|
||||
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
php_sock = Z_SOCKET_P(zsocket);
|
||||
ENSURE_SOCKET_VALID(php_sock);
|
||||
|
||||
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_send,
|
||||
sizeof(*msghdr), "msghdr", &allocations, &err);
|
||||
|
@ -216,17 +214,14 @@ PHP_FUNCTION(socket_recvmsg)
|
|||
struct err_s err = {0};
|
||||
|
||||
//ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ra|l",
|
||||
&zsocket, &zmsg, &flags) == FAILURE) {
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oa|l", &zsocket, socket_ce, &zmsg, &flags) == FAILURE) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
LONG_CHECK_VALID_INT(flags, 3);
|
||||
|
||||
if ((php_sock = (php_socket *)zend_fetch_resource(Z_RES_P(zsocket),
|
||||
php_sockets_le_socket_name, php_sockets_le_socket())) == NULL) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
php_sock = Z_SOCKET_P(zsocket);
|
||||
ENSURE_SOCKET_VALID(php_sock);
|
||||
|
||||
msghdr = from_zval_run_conversions(zmsg, php_sock, from_zval_write_msghdr_recv,
|
||||
sizeof(*msghdr), "msghdr", &allocations, &err);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,140 +2,116 @@
|
|||
|
||||
/** @generate-function-entries */
|
||||
|
||||
final class Socket
|
||||
{
|
||||
}
|
||||
|
||||
final class AddressInfo
|
||||
{
|
||||
}
|
||||
|
||||
function socket_select(?array &$read_fds, ?array &$write_fds, ?array &$except_fds, ?int $tv_sec, int $tv_usec = 0): int|false {}
|
||||
|
||||
/** @return resource|false */
|
||||
function socket_create_listen(int $port, int $backlog = 128) {}
|
||||
function socket_create_listen(int $port, int $backlog = 128): Socket|false {}
|
||||
|
||||
function socket_accept(Socket $socket): Socket|false {}
|
||||
|
||||
function socket_set_nonblock(Socket $socket): bool {}
|
||||
|
||||
function socket_set_block(Socket $socket): bool {}
|
||||
|
||||
function socket_listen(Socket $socket, int $backlog = 0): bool {}
|
||||
|
||||
function socket_close(Socket $socket): void {}
|
||||
|
||||
function socket_write(Socket $socket, string $buf, ?int $length = null): int|false {}
|
||||
|
||||
function socket_read(Socket $socket, int $length, int $type = PHP_BINARY_READ): string|false {}
|
||||
|
||||
/**
|
||||
* @param resource $socket
|
||||
* @return resource|false
|
||||
* @param string $addr
|
||||
* @param int $port
|
||||
*/
|
||||
function socket_accept($socket) {}
|
||||
function socket_getsockname(Socket $socket, &$addr, &$port = UNKNOWN): bool {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_set_nonblock($socket): bool {}
|
||||
/**
|
||||
* @param string $addr
|
||||
* @param int $port
|
||||
*/
|
||||
function socket_getpeername(Socket $socket, &$addr, &$port = UNKNOWN): bool {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_set_block($socket): bool {}
|
||||
function socket_create(int $domain, int $type, int $protocol): Socket|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_listen($socket, int $backlog = 0): bool {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_close($socket): void {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_write($socket, string $buf, int $length = UNKNOWN): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_read($socket, int $length, int $type = PHP_BINARY_READ): string|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_getsockname($socket, &$addr, &$port = UNKNOWN): bool {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_getpeername($socket, &$addr, &$port = UNKNOWN): bool {}
|
||||
|
||||
/** @return resource|false */
|
||||
function socket_create(int $domain, int $type, int $protocol) {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_connect($socket, string $addr, int $port = UNKNOWN): bool {}
|
||||
function socket_connect(Socket $socket, string $addr, ?int $port = null): bool {}
|
||||
|
||||
function socket_strerror(int $errno): string {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_bind($socket, string $addr, int $port = 0): bool {}
|
||||
function socket_bind(Socket $socket, string $addr, int $port = 0): bool {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_recv($socket, &$buf, int $len, int $flags): int|false {}
|
||||
function socket_recv(Socket $socket, &$buf, int $len, int $flags): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_send($socket, string $buf, int $len, int $flags): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_recvfrom($socket, &$buf, int $len, int $flags, &$name, &$port = UNKNOWN): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_sendto($socket, string $buf, int $len, int $flags, string $addr, int $port = 0): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_get_option($socket, int $level, int $optname): array|int|false {}
|
||||
function socket_send(Socket $socket, string $buf, int $len, int $flags): int|false {}
|
||||
|
||||
/**
|
||||
* @param resource $socket
|
||||
* @alias socket_get_option
|
||||
* @param string $buf
|
||||
* @param string $name
|
||||
* @param int $port
|
||||
*/
|
||||
function socket_getopt($socket, int $level, int $optname): array|int|false {}
|
||||
function socket_recvfrom(Socket $socket, &$buf, int $len, int $flags, &$name, &$port = UNKNOWN): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_set_option($socket, int $level, int $optname, $optval): bool {}
|
||||
function socket_sendto(Socket $socket, string $buf, int $len, int $flags, string $addr, ?int $port = null): int|false {}
|
||||
|
||||
function socket_get_option(Socket $socket, int $level, int $optname): array|int|false {}
|
||||
|
||||
/** @alias socket_get_option */
|
||||
function socket_getopt(Socket $socket, int $level, int $optname): array|int|false {}
|
||||
|
||||
/** @param array|string|int $optval */
|
||||
function socket_set_option(Socket $socket, int $level, int $optname, $optval): bool {}
|
||||
|
||||
/**
|
||||
* @param resource $socket
|
||||
* @param array|string|int $optval
|
||||
* @alias socket_set_option
|
||||
*/
|
||||
function socket_setopt($socket, int $level, int $optname, $optval): bool {}
|
||||
function socket_setopt(Socket $socket, int $level, int $optname, $optval): bool {}
|
||||
|
||||
#ifdef HAVE_SOCKETPAIR
|
||||
/** @param array $fd */
|
||||
function socket_create_pair(int $domain, int $type, int $protocol, &$fd): bool|null {}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SHUTDOWN
|
||||
/** @param resource $socket */
|
||||
function socket_shutdown($socket, int $how = 2): bool {}
|
||||
function socket_shutdown(Socket $socket, int $how = 2): bool {}
|
||||
#endif
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_last_error($socket = UNKNOWN): int {}
|
||||
function socket_last_error(?Socket $socket = null): int {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_clear_error($socket = UNKNOWN): void {}
|
||||
function socket_clear_error(?Socket $socket = null): void {}
|
||||
|
||||
/**
|
||||
* @param resource $stream
|
||||
* @return resource|false
|
||||
*/
|
||||
function socket_import_stream($stream) {}
|
||||
/** @param resource $stream */
|
||||
function socket_import_stream($stream): Socket|false {}
|
||||
|
||||
/**
|
||||
* @param resource $socket
|
||||
* @return resource|false
|
||||
*/
|
||||
function socket_export_stream($socket) {}
|
||||
/** @return resource|false */
|
||||
function socket_export_stream(Socket $socket) {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_sendmsg($socket, array $msghdr, int $flags = 0): int|false {}
|
||||
function socket_sendmsg(Socket $socket, array $msghdr, int $flags = 0): int|false {}
|
||||
|
||||
/** @param resource $socket */
|
||||
function socket_recvmsg($socket, array &$msghdr, int $flags = 0): int|false {}
|
||||
function socket_recvmsg(Socket $socket, array &$msghdr, int $flags = 0): int|false {}
|
||||
|
||||
function socket_cmsg_space(int $level, int $type, int $n = 0): ?int {}
|
||||
|
||||
function socket_addrinfo_lookup(string $host, string $service = UNKNOWN, array $hints = UNKNOWN): array|false {}
|
||||
function socket_addrinfo_lookup(string $host, ?string $service = null, array $hints = []): array|false {}
|
||||
|
||||
/**
|
||||
* @param resource $addr
|
||||
* @return resource|false
|
||||
*/
|
||||
function socket_addrinfo_connect($addr) {}
|
||||
function socket_addrinfo_connect(AddressInfo $addr): Socket|false {}
|
||||
|
||||
/**
|
||||
* @param resource $addr
|
||||
* @return resource|false
|
||||
*/
|
||||
function socket_addrinfo_bind($addr) {}
|
||||
function socket_addrinfo_bind(AddressInfo $addr): Socket|false {}
|
||||
|
||||
/** @param resource $addr */
|
||||
function socket_addrinfo_explain($addr): array {}
|
||||
function socket_addrinfo_explain(AddressInfo $addr): array {}
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
/** @param resource $socket */
|
||||
function socket_wsaprotocol_info_export($socket, int $target_pid): string|false {}
|
||||
function socket_wsaprotocol_info_export(Socket $socket, int $target_pid): string|false {}
|
||||
|
||||
/** @return resource|false */
|
||||
function socket_wsaprotocol_info_import(string $info_id) {}
|
||||
function socket_wsaprotocol_info_import(string $info_id): Socket|false {}
|
||||
|
||||
function socket_wsaprotocol_info_release(string $info_id): bool {}
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 4494f9f246dbc98047d97d913cc1add9f91eb0ff */
|
||||
* Stub hash: 3256069f3943ec6dac1db915d737324962dda7c4 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(1, read_fds, IS_ARRAY, 1)
|
||||
|
@ -9,60 +9,60 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG
|
|||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, tv_usec, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_create_listen, 0, 0, 1)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_create_listen, 0, 1, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, backlog, IS_LONG, 0, "128")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_accept, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_accept, 0, 1, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_set_nonblock, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_socket_set_block arginfo_socket_set_nonblock
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_listen, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, backlog, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_close, 0, 1, IS_VOID, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_write, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, buf, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_read, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, length, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "PHP_BINARY_READ")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_getsockname, 0, 2, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_INFO(1, addr)
|
||||
ZEND_ARG_INFO(1, port)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_socket_getpeername arginfo_socket_getsockname
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_create, 0, 0, 3)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_create, 0, 3, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, domain, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, protocol, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_connect, 0, 2, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, addr, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_strerror, 0, 1, IS_STRING, 0)
|
||||
|
@ -70,27 +70,27 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_strerror, 0, 1, IS_STRING
|
|||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_bind, 0, 2, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, addr, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recv, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_INFO(1, buf)
|
||||
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_send, 0, 4, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, buf, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recvfrom, 0, 5, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_INFO(1, buf)
|
||||
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
|
||||
|
@ -99,16 +99,16 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recvfrom, 0, 5, MAY_BE_LO
|
|||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_sendto, 0, 5, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, buf, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, addr, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_get_option, 0, 3, MAY_BE_ARRAY|MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, optname, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -116,7 +116,7 @@ ZEND_END_ARG_INFO()
|
|||
#define arginfo_socket_getopt arginfo_socket_get_option
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_set_option, 0, 4, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, level, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, optname, IS_LONG, 0)
|
||||
ZEND_ARG_INFO(0, optval)
|
||||
|
@ -135,33 +135,35 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
#if defined(HAVE_SHUTDOWN)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_shutdown, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, how, IS_LONG, 0, "2")
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_last_error, 0, 0, IS_LONG, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, socket, Socket, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_clear_error, 0, 0, IS_VOID, 0)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, socket, Socket, 1, "null")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_import_stream, 0, 0, 1)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_import_stream, 0, 1, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, stream)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_socket_export_stream arginfo_socket_accept
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_export_stream, 0, 0, 1)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_sendmsg, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, msghdr, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recvmsg, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(1, msghdr, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
@ -174,29 +176,29 @@ ZEND_END_ARG_INFO()
|
|||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_addrinfo_lookup, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, service, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, hints, IS_ARRAY, 0)
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, service, IS_STRING, 1, "null")
|
||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, hints, IS_ARRAY, 0, "[]")
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_addrinfo_connect, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, addr)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_addrinfo_connect, 0, 1, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_OBJ_INFO(0, addr, AddressInfo, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_socket_addrinfo_bind arginfo_socket_addrinfo_connect
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_addrinfo_explain, 0, 1, IS_ARRAY, 0)
|
||||
ZEND_ARG_INFO(0, addr)
|
||||
ZEND_ARG_OBJ_INFO(0, addr, AddressInfo, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#if defined(PHP_WIN32)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_wsaprotocol_info_export, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
|
||||
ZEND_ARG_INFO(0, socket)
|
||||
ZEND_ARG_OBJ_INFO(0, socket, Socket, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, target_pid, IS_LONG, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
#if defined(PHP_WIN32)
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_wsaprotocol_info_import, 0, 0, 1)
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_socket_wsaprotocol_info_import, 0, 1, Socket, MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, info_id, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
@ -309,3 +311,13 @@ static const zend_function_entry ext_functions[] = {
|
|||
#endif
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
|
||||
static const zend_function_entry class_Socket_methods[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
|
||||
static const zend_function_entry class_AddressInfo_methods[] = {
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
|
|
@ -158,7 +158,8 @@ bool(true)
|
|||
creating unbound socket and hoping the routing table causes an interface other than lo to be used for sending messages to 224.0.0.23
|
||||
bool(true)
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
bool(true)
|
||||
int(14)
|
||||
|
|
|
@ -180,9 +180,11 @@ if ($i == 8) {
|
|||
}
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
bool(true)
|
||||
int(14)
|
||||
|
|
|
@ -108,9 +108,11 @@ if ($i == 3) {
|
|||
}
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
bool(true)
|
||||
int(14)
|
||||
|
|
|
@ -13,6 +13,7 @@ $addrinfo = socket_addrinfo_lookup('127.0.0.1', 2000, array(
|
|||
));
|
||||
var_dump(socket_addrinfo_bind($addrinfo[0]));
|
||||
echo "Done";
|
||||
--EXPECTF--
|
||||
resource(%d) of type (Socket)
|
||||
--EXPECT--
|
||||
object(Socket)#2 (0) {
|
||||
}
|
||||
Done
|
||||
|
|
|
@ -13,6 +13,7 @@ $addrinfo = socket_addrinfo_lookup('127.0.0.1', 2000, array(
|
|||
));
|
||||
var_dump(socket_addrinfo_connect($addrinfo[0]));
|
||||
echo "Done";
|
||||
--EXPECTF--
|
||||
resource(%d) of type (Socket)
|
||||
--EXPECT--
|
||||
object(Socket)#2 (0) {
|
||||
}
|
||||
Done
|
||||
|
|
|
@ -16,5 +16,6 @@ var_dump($addrinfo[0]);
|
|||
echo "Done";
|
||||
--EXPECTF--
|
||||
Notice: socket_addrinfo_lookup(): Unknown hint invalid in %ssocket_addrinfo_lookup.php on line %d
|
||||
resource(%d) of type (AddressInfo)
|
||||
object(AddressInfo)#%d (0) {
|
||||
}
|
||||
Done
|
||||
|
|
|
@ -58,9 +58,11 @@ $pid = getmypid();
|
|||
var_dump($data['control'][0]['data']['pid'] === $pid);
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
int(5)
|
||||
Array
|
||||
|
|
|
@ -79,9 +79,11 @@ if ($data["control"]) {
|
|||
}
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
int(11)
|
||||
array(3) {
|
||||
|
|
|
@ -17,22 +17,21 @@ socket_getsockname($s_c, $addr, $port);
|
|||
|
||||
// wrong parameter count
|
||||
try {
|
||||
$s_w = socket_connect($s_c);
|
||||
socket_connect($s_c);
|
||||
} catch (\ArgumentCountError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
try {
|
||||
$s_w = socket_connect($s_c, '0.0.0.0');
|
||||
socket_connect($s_c, '0.0.0.0');
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
$s_w = socket_connect($s_c, '0.0.0.0', $port);
|
||||
|
||||
socket_close($s_c);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
socket_connect() expects at least 2 parameters, 1 given
|
||||
socket_connect(): Argument #3 ($port) must be specified for the AF_INET socket type
|
||||
socket_connect(): Argument #3 ($port) cannot be null when the socket type is AF_INET
|
||||
|
||||
Warning: socket_connect(): unable to connect [%i]: %a in %s on line %d
|
||||
|
|
|
@ -21,7 +21,8 @@ fa@php.net
|
|||
socket_close($s_c_l);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%i) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
|
||||
Warning: socket_create_listen(): unable to bind to given address [%i]: %a in %s on line %d
|
||||
bool(false)
|
||||
|
|
|
@ -18,7 +18,9 @@ var_dump($sockets);
|
|||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
resource(4) of type (Socket)
|
||||
object(Socket)#1 (0) {
|
||||
}
|
||||
[1]=>
|
||||
resource(5) of type (Socket)
|
||||
object(Socket)#2 (0) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,30 +9,31 @@ if (!extension_loaded('sockets')) {
|
|||
<?php
|
||||
|
||||
try {
|
||||
var_dump(socket_export_stream(fopen(__FILE__, "rb")));
|
||||
socket_export_stream(fopen(__FILE__, "rb"));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
var_dump(socket_export_stream(stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND)));
|
||||
socket_export_stream(stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BIND));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
||||
var_dump($s);
|
||||
socket_close($s);
|
||||
|
||||
try {
|
||||
var_dump(socket_export_stream($s));
|
||||
} catch (TypeError $e) {
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
|
||||
echo "Done.";
|
||||
?>
|
||||
--EXPECTF--
|
||||
socket_export_stream(): supplied resource is not a valid Socket resource
|
||||
socket_export_stream(): supplied resource is not a valid Socket resource
|
||||
resource(%d) of type (Socket)
|
||||
socket_export_stream(): supplied resource is not a valid Socket resource
|
||||
socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
|
||||
socket_export_stream(): Argument #1 ($socket) must be of type Socket, resource given
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
socket_export_stream(): Argument #1 ($socket) has already been closed
|
||||
Done.
|
||||
|
|
|
@ -40,7 +40,8 @@ echo "Done.\n";
|
|||
--EXPECTF--
|
||||
resource(%d) of type (stream)
|
||||
bool(true)
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
int(10)
|
||||
string(10) "my message"
|
||||
Done.
|
||||
|
|
|
@ -16,8 +16,8 @@ function test($stream, $sock) {
|
|||
echo "stream_set_blocking ";
|
||||
try {
|
||||
print_r(stream_set_blocking($stream, 0));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
@ -25,15 +25,15 @@ function test($stream, $sock) {
|
|||
echo "socket_set_block ";
|
||||
try {
|
||||
print_r(socket_set_block($sock));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
echo "socket_get_option ";
|
||||
try {
|
||||
print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ stream_set_blocking 1
|
|||
|
||||
|
||||
close stream
|
||||
stream_set_blocking stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
|
||||
socket_set_block
|
||||
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
|
||||
|
@ -103,11 +103,11 @@ Warning: socket_get_option(): Unable to retrieve socket option [%d]: %s in %s on
|
|||
|
||||
|
||||
close socket
|
||||
stream_set_blocking stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
|
||||
socket_set_block socket_set_block(): supplied resource is not a valid Socket resource
|
||||
socket_set_block Error: socket_set_block(): Argument #1 ($socket) has already been closed
|
||||
|
||||
socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
|
||||
socket_get_option Error: socket_get_option(): Argument #1 ($socket) has already been closed
|
||||
|
||||
|
||||
Done.
|
||||
|
|
|
@ -7,6 +7,9 @@ if (!extension_loaded('sockets')) {
|
|||
}
|
||||
if (!function_exists('zend_leak_variable'))
|
||||
die('SKIP only for debug builds');
|
||||
?>
|
||||
--INI--
|
||||
report_memleaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -21,5 +21,6 @@ socket_close($sock);
|
|||
|
||||
var_dump(stream_get_contents($s1));
|
||||
--EXPECTF--
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
string(12) "test message"
|
||||
|
|
|
@ -10,7 +10,7 @@ if (!extension_loaded('sockets')) {
|
|||
|
||||
var_dump(socket_import_stream(fopen(__FILE__, "rb")));
|
||||
try {
|
||||
var_dump(socket_import_stream(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP)));
|
||||
socket_import_stream(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ $s = stream_socket_server("udp://127.0.0.1:0", $errno, $errstr, STREAM_SERVER_BI
|
|||
var_dump($s);
|
||||
var_dump(fclose($s));
|
||||
try {
|
||||
var_dump(socket_import_stream($s));
|
||||
socket_import_stream($s);
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ echo "Done.";
|
|||
--EXPECTF--
|
||||
Warning: socket_import_stream(): Cannot represent a stream of type STDIO as a Socket Descriptor in %s on line %d
|
||||
bool(false)
|
||||
socket_import_stream(): supplied resource is not a valid stream resource
|
||||
socket_import_stream(): Argument #1 ($stream) must be of type resource, Socket given
|
||||
resource(%d) of type (stream)
|
||||
bool(true)
|
||||
socket_import_stream(): supplied resource is not a valid stream resource
|
||||
|
|
|
@ -37,9 +37,11 @@ stream_set_blocking($stream, 0);
|
|||
var_dump(fread($stream, strlen($m)));
|
||||
echo "Done.\n";
|
||||
--EXPECTF--
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
int(10)
|
||||
string(10) "my message"
|
||||
Done.
|
||||
|
|
|
@ -16,8 +16,8 @@ function test($stream, $sock) {
|
|||
echo "stream_set_blocking ";
|
||||
try {
|
||||
print_r(stream_set_blocking($stream, 0));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
@ -25,15 +25,15 @@ function test($stream, $sock) {
|
|||
echo "socket_set_block ";
|
||||
try {
|
||||
print_r(socket_set_block($sock));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
echo "socket_get_option ";
|
||||
try {
|
||||
print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE));
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
} catch (Error $e) {
|
||||
echo get_class($e), ": ", $e->getMessage(), "\n";
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ stream_set_blocking 1
|
|||
|
||||
|
||||
close stream
|
||||
stream_set_blocking stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
|
||||
socket_set_block
|
||||
Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
|
||||
|
@ -98,11 +98,11 @@ Warning: socket_get_option(): Unable to retrieve socket option [%d]: %s in %s on
|
|||
|
||||
|
||||
close socket
|
||||
stream_set_blocking stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource
|
||||
|
||||
socket_set_block socket_set_block(): supplied resource is not a valid Socket resource
|
||||
socket_set_block Error: socket_set_block(): Argument #1 ($socket) has already been closed
|
||||
|
||||
socket_get_option socket_get_option(): supplied resource is not a valid Socket resource
|
||||
socket_get_option Error: socket_get_option(): Argument #1 ($socket) has already been closed
|
||||
|
||||
|
||||
Done.
|
||||
|
|
|
@ -7,6 +7,9 @@ if (!extension_loaded('sockets')) {
|
|||
}
|
||||
if (!function_exists('zend_leak_variable'))
|
||||
die('SKIP only for debug builds');
|
||||
?>
|
||||
--INI--
|
||||
report_memleaks=0
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
|
|
|
@ -49,10 +49,12 @@ if (!socket_recvmsg($s, $data, 0)) die("recvmsg");
|
|||
print_r($data);
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
int(14)
|
||||
Array
|
||||
|
|
|
@ -11,10 +11,14 @@ $sockets = null;
|
|||
$write = null;
|
||||
$except = null;
|
||||
$time = 0;
|
||||
var_dump(socket_select($sockets, $write, $except, $time));
|
||||
|
||||
try {
|
||||
socket_select($sockets, $write, $except, $time);
|
||||
} catch (ValueError $exception) {
|
||||
echo $exception->getMessage() . "\n";
|
||||
}
|
||||
--EXPECTF--
|
||||
Warning: socket_select(): No resource arrays were passed to select in %s on line %d
|
||||
bool(false)
|
||||
socket_select(): At least one array argument must be passed
|
||||
--CREDITS--
|
||||
Till Klampaeckel, till@php.net
|
||||
Berlin TestFest 2009
|
||||
|
|
|
@ -14,4 +14,4 @@ try {
|
|||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
socket_select(): supplied argument is not a valid Socket resource
|
||||
socket_select(): Argument #1 ($read_fds) must only have elements of type Socket, string given
|
||||
|
|
|
@ -62,10 +62,12 @@ if (!socket_recvmsg($s, $data, 0)) die("recvmsg");
|
|||
print_r($data);
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(5) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
creating receive socket
|
||||
resource(6) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
int(11)
|
||||
Array
|
||||
|
|
|
@ -56,10 +56,12 @@ if (!socket_recvmsg($s, $data, 0)) die("recvmsg");
|
|||
print_r($data);
|
||||
--EXPECTF--
|
||||
creating send socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
creating receive socket
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
bool(true)
|
||||
int(11)
|
||||
Array
|
||||
|
|
|
@ -17,14 +17,11 @@ $socket2 = socket_create_listen(31340);
|
|||
socket_close($socket2);
|
||||
try {
|
||||
var_dump(socket_set_block($socket2));
|
||||
} catch (TypeError $e) {
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
socket_set_block(): supplied resource is not a valid Socket resource
|
||||
--CREDITS--
|
||||
Robin Mehner, robin@coding-robin.de
|
||||
PHP Testfest Berlin 2009-05-09
|
||||
socket_set_block(): Argument #1 ($socket) has already been closed
|
||||
|
|
|
@ -17,14 +17,11 @@ $socket2 = socket_create_listen(31340);
|
|||
socket_close($socket2);
|
||||
try {
|
||||
var_dump(socket_set_nonblock($socket2));
|
||||
} catch (TypeError $e) {
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
socket_set_nonblock(): supplied resource is not a valid Socket resource
|
||||
--CREDITS--
|
||||
Robin Mehner, robin@coding-robin.de
|
||||
PHP Testfest Berlin 2009-05-09
|
||||
socket_set_nonblock(): Argument #1 ($socket) has already been closed
|
||||
|
|
|
@ -17,5 +17,6 @@ fa@php.net
|
|||
//socket_accept($s_c_l);
|
||||
socket_close($s_c_l);
|
||||
?>
|
||||
--EXPECTF--
|
||||
resource(%i) of type (Socket)
|
||||
--EXPECT--
|
||||
object(Socket)#1 (0) {
|
||||
}
|
||||
|
|
|
@ -48,9 +48,12 @@ if (!extension_loaded('sockets')) {
|
|||
?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
resource(%d) of type (Socket)
|
||||
resource(%d) of type (Socket)
|
||||
resource(%d) of type (Socket)
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
object(Socket)#%d (0) {
|
||||
}
|
||||
resource(%d) of type (Unknown)
|
||||
|
||||
Warning: socket_wsaprotocol_info_export(): Unable to export WSA protocol info [0x00002726]: %s
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue