@@ -253,6 +253,65 @@ function dns_get_record(string $hostname, int $type = DNS_ANY, array &$authns =
253253}
254254
255255
256+ /**
257+ * Initiates a socket connection to the resource specified by
258+ * hostname.
259+ *
260+ * PHP supports targets in the Internet and Unix domains as described in
261+ * . A list of supported transports can also be
262+ * retrieved using stream_get_transports.
263+ *
264+ * The socket will by default be opened in blocking mode. You can
265+ * switch it to non-blocking mode by using
266+ * stream_set_blocking.
267+ *
268+ * The function stream_socket_client is similar but
269+ * provides a richer set of options, including non-blocking connection and the
270+ * ability to provide a stream context.
271+ *
272+ * @param string $hostname If OpenSSL support is
273+ * installed, you may prefix the hostname
274+ * with either ssl:// or tls:// to
275+ * use an SSL or TLS client connection over TCP/IP to connect to the
276+ * remote host.
277+ * @param int $port The port number. This can be omitted and skipped with
278+ * -1 for transports that do not use ports, such as
279+ * unix://.
280+ * @param int $errno If provided, holds the system level error number that occurred in the
281+ * system-level connect() call.
282+ *
283+ * If the value returned in errno is
284+ * 0 and the function returned FALSE, it is an
285+ * indication that the error occurred before the
286+ * connect() call. This is most likely due to a
287+ * problem initializing the socket.
288+ * @param string $errstr The error message as a string.
289+ * @param float $timeout The connection timeout, in seconds.
290+ *
291+ * If you need to set a timeout for reading/writing data over the
292+ * socket, use stream_set_timeout, as the
293+ * timeout parameter to
294+ * fsockopen only applies while connecting the
295+ * socket.
296+ * @return resource fsockopen returns a file pointer which may be used
297+ * together with the other file functions (such as
298+ * fgets, fgetss,
299+ * fwrite, fclose, and
300+ * feof). If the call fails, it will return FALSE
301+ * @throws NetworkException
302+ *
303+ */
304+ function fsockopen (string $ hostname , int $ port = -1 , int &$ errno = null , string &$ errstr = null , float $ timeout = null )
305+ {
306+ error_clear_last ();
307+ $ result = \fsockopen ($ hostname , $ port , $ errno , $ errstr , $ timeout );
308+ if ($ result === false ) {
309+ throw NetworkException::createFromPhpError ();
310+ }
311+ return $ result ;
312+ }
313+
314+
256315/**
257316 * getprotobyname returns the protocol number
258317 * associated with the protocol name as per
0 commit comments