I'm trying to work with teamspeak on my pc, but because of simplicity I wanna use my raspberry PI to execute the script, so I'm just writing my script:
<?php
error_reporting(E_ALL);
ob_implicit_flush();
$address = "192.168.2.11";
$service_port = 25639;
$socket = socket_create(AF_INET, SOCK_STREAM, 0);
if($socket === false)
{
die("Error: " . socket_strerror(socket_last_error())."
");
}
echo "Connecting to {$address}:{$service_port}...
";
$result = socket_connect($socket, $address, $service_port);
if($result === false)
{
die("Error: ".socket_strerror(socket_last_error($socket))."
");
}
echo socket_read($socket, 512);
?>
But everytime I run it, it just gives me:
Connecting to 192.168.2.11:25639...
and no further messages. I am thinking the error is at socket_create
, but changing the parameters just throws errors.
I googled and searched on stack, but it looks like I'm the only one that has this issue. :/
Try running this:
<?php
$host="192.168.2.11" ;
$port=25639;
$timeout=30;
$sk=fsockopen($host,$port,$errnum,$errstr,$timeout) ;
if (!is_resource($sk)) {
exit("connection fail: ".$errnum." ".$errstr) ;
} else {
echo "Connected";
}
?>