fsockopen 不工作?
我正在尝试使用 Windows 7 在命令行上通过 PHP 连接到 IRC 服务器。
每次运行此命令时:
$socket = fsockopen($irc_server, 6667, $errno, $errstr, 5);
$errno
= 0, $errstr
= "" 和 < code>$socket = 'Resource id #4' (using die($socket);
) 造成
这种情况的原因是什么,以及如何对此进行更多调试。
以下代码:
$s = fsockopen("google.com", 80, $errno, $errstr, 5);
die($errno.", ".$errstr.", ".$s);
...返回以下内容:
0, , Resource id #4
我无法使用 $socket
。当我尝试使用它时,它显示“无效资源”。另外,PHP 文档指出 errno 0 表示套接字打开错误。
感谢帮助。
I am trying to connect to an IRC server via PHP on a command line using Windows 7.
Everytime when running this:
$socket = fsockopen($irc_server, 6667, $errno, $errstr, 5);
$errno
= 0, $errstr
= "" and $socket
= 'Resource id #4' (using die($socket);
)
What is the cause of this, and how can I debug more into this.
The following code:
$s = fsockopen("google.com", 80, $errno, $errstr, 5);
die($errno.", ".$errstr.", ".$s);
...returns the following:
0, , Resource id #4
I can't use $socket
. It says "Invalid resource" when I try to use it. Also, the PHP documentation notes that errno 0 indicates a wrongly opened socket.
Help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您能给我们展示更多您的代码吗?
这段代码会发生什么:
?
Could you show us a little more of your code?
What happens with this code:
?
我修好了。
函数 irCmd 不知道 $socket,所以我把它放在它前面:
它起作用了。非常感谢!
I fixed it.
function irCmd didn't know $socket, so I put this in front of it:
And it worked. Thanks a bunch!
文件说(强调我的):
由于该函数没有返回 false,因此套接字有效。如果您还有其他问题,请告诉我们是什么问题;这里
fsockopen
已经正常返回了。The documentation says (emphasis mine):
Since the function did not return false, the socket is valid. If you are having further problems, tells us what they are;
fsockopen
has returned normally here.