Question

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. I've also tried using port 5555 and using the server name 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.

Was it helpful?

Solution

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

Says: 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.

So, check your hosts first whether valid or not.

OTHER TIPS

You needed to set your firewall to allow 6667 ports i expect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top