pfsockopen

(PHP 4, PHP 5, PHP 7, PHP 8)

pfsockopen打开持久的 Internet 或 Unix 套接字连接

说明

pfsockopen(
    string $hostname,
    int $port = -1,
    int &$error_code = null,
    string &$error_message = null,
    ?float $timeout = null
): resource|false

这个函数的作用与 fsockopen() 完全一样,不同的地方在于当在脚本执行完后,连接一直不会关闭。可以说它是 fsockopen() 的长连接版本。

参数

对于其参数的信息,请参考 fsockopen() 的文档。

返回值

pfsockopen() 返回文件指针,可以跟其他文件函数(比如 fgets()fgetss()fwrite()fclose()feof())一起使用, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 timeout 现在可以为 null。

参见

  • fsockopen() - 打开 Internet 或者 Unix 套接字连接

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top