简体   繁体   English

我的PHP脚本无法连接到IRC服务器

[英]My PHP script can't connect to an IRC server

I can't for the life of me figure out what I am doing wrong. 我不能为我的生活弄清楚我做错了什么。 I am using $sock = fsockopen("irc.esper.net", 6667) to try to connect to the server. 我正在使用$sock = fsockopen("irc.esper.net", 6667)来尝试连接到服务器。 I've also tried using port 5555 and using the server name aperture.esper.net. 我也尝试使用端口5555并使用服务器名称aperture.esper.net。 All of which fail with either a timeout or network not reachable error (checked the logs). 所有这些都因超时或网络无法访问错误而失败(检查日志)。 The whole code is here: 整个代码在这里:

<?php

set_time_limit(0);

$sock = fsockopen("irc.ipv6.esper.net", 6667);

echo("Joined");

if (!$sock) {
    exit(1);
}

fputs($sock, "USER kodas2_ :kodas2_");
fputs($sock, "NICK h1a2r\r\n");
fputs($sock, "JOIN #minecraft\r\n");

while (true) {

}
?>

Thanks for any replies. 谢谢你的回复。

$sock =@ fsockopen("irc.esper.net", 6667, $errno, $errstr, 30);
if ($sock) {
    printf("No error, go on.");
}

Says: No error, go on. 说: No error, go on.

$sock =@ fsockopen("irc.ipv6.esper.net", 6667, $errno, $errstr, 30);
if (!$sock) {
    printf("errno: %s, errstr: %s", $errno, $errstr);
}

Says: errno: 0, errstr: php_network_getaddresses: getaddrinfo failed: No such host is known. 说: errno: 0, errstr: php_network_getaddresses: getaddrinfo failed: No such host is known.

So, check your hosts first whether valid or not. 因此,请先检查您的主机是否有效。

您需要设置防火墙以允许我期望的6667端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM