xref: /PHP-8.1/ext/sockets/sockets.stub.php (revision d9e5e630)
1<?php
2
3/** @generate-class-entries */
4
5/**
6 * @strict-properties
7 * @not-serializable
8 */
9final class Socket
10{
11}
12
13/**
14 * @strict-properties
15 * @not-serializable
16 */
17final class AddressInfo
18{
19}
20
21function socket_select(?array &$read, ?array &$write, ?array &$except, ?int $seconds, int $microseconds = 0): int|false {}
22
23function socket_create_listen(int $port, int $backlog = 128): Socket|false {}
24
25function socket_accept(Socket $socket): Socket|false {}
26
27function socket_set_nonblock(Socket $socket): bool {}
28
29function socket_set_block(Socket $socket): bool {}
30
31function socket_listen(Socket $socket, int $backlog = 0): bool {}
32
33function socket_close(Socket $socket): void {}
34
35function socket_write(Socket $socket, string $data, ?int $length = null): int|false {}
36
37function socket_read(Socket $socket, int $length, int $mode = PHP_BINARY_READ): string|false {}
38
39/**
40 * @param string $address
41 * @param int $port
42 */
43function socket_getsockname(Socket $socket, &$address, &$port = null): bool {}
44
45/**
46 * @param string $address
47 * @param int $port
48 */
49function socket_getpeername(Socket $socket, &$address, &$port = null): bool {}
50
51function socket_create(int $domain, int $type, int $protocol): Socket|false {}
52
53function socket_connect(Socket $socket, string $address, ?int $port = null): bool {}
54
55function socket_strerror(int $error_code): string {}
56
57function socket_bind(Socket $socket, string $address, int $port = 0): bool {}
58
59/** @param string|null $data */
60function socket_recv(Socket $socket, &$data, int $length, int $flags): int|false {}
61
62function socket_send(Socket $socket, string $data, int $length, int $flags): int|false {}
63
64/**
65 * @param string $data
66 * @param string $address
67 * @param int $port
68 */
69function socket_recvfrom(Socket $socket, &$data, int $length, int $flags, &$address, &$port = null): int|false {}
70
71function socket_sendto(Socket $socket, string $data, int $length, int $flags, string $address, ?int $port = null): int|false {}
72
73/**
74 * @return array<string, mixed>|int|false
75 * @refcount 1
76 */
77function socket_get_option(Socket $socket, int $level, int $option): array|int|false {}
78
79/**
80 * @return array<string, mixed>|int|false
81 * @alias socket_get_option
82 */
83function socket_getopt(Socket $socket, int $level, int $option): array|int|false {}
84
85/** @param array|string|int $value */
86function socket_set_option(Socket $socket, int $level, int $option, $value): bool {}
87
88/**
89 * @param array|string|int $value
90 * @alias socket_set_option
91 */
92function socket_setopt(Socket $socket, int $level, int $option, $value): bool {}
93
94#ifdef HAVE_SOCKETPAIR
95/** @param array $pair */
96function socket_create_pair(int $domain, int $type, int $protocol, &$pair): bool {}
97#endif
98
99#ifdef HAVE_SHUTDOWN
100function socket_shutdown(Socket $socket, int $mode = 2): bool {}
101#endif
102
103function socket_last_error(?Socket $socket = null): int {}
104
105function socket_clear_error(?Socket $socket = null): void {}
106
107/** @param resource $stream */
108function socket_import_stream($stream): Socket|false {}
109
110/** @return resource|false */
111function socket_export_stream(Socket $socket) {}
112
113function socket_sendmsg(Socket $socket, array $message, int $flags = 0): int|false {}
114
115function socket_recvmsg(Socket $socket, array &$message, int $flags = 0): int|false {}
116
117function socket_cmsg_space(int $level, int $type, int $num = 0): ?int {}
118
119/**
120 * @return array<int, AddressInfo>|false
121 * @refcount 1
122 */
123function socket_addrinfo_lookup(string $host, ?string $service = null, array $hints = []): array|false {}
124
125function socket_addrinfo_connect(AddressInfo $address): Socket|false {}
126
127function socket_addrinfo_bind(AddressInfo $address): Socket|false {}
128
129/**
130 * @return array<string, int|string|array>
131 * @refcount 1
132 */
133function socket_addrinfo_explain(AddressInfo $address): array {}
134
135#ifdef PHP_WIN32
136function socket_wsaprotocol_info_export(Socket $socket, int $process_id): string|false {}
137
138function socket_wsaprotocol_info_import(string $info_id): Socket|false {}
139
140function socket_wsaprotocol_info_release(string $info_id): bool {}
141#endif
142