Local socket connection - [13] Permission denied

Moderator: Telldus

Post Reply
elyobelyob
Posts: 4
Joined: Fri Mar 17, 2023 9:45 am

Local socket connection - [13] Permission denied

Post by elyobelyob »

Can anyone explain how I can connect from a raspberry pi to Tellstick Net?
I try this and get a permission failed ...

# php discover.php
Socket created
Enter a message to send : D
Couldn't create socket for send: [13] Permission denied

Code: Select all

<?php

/*
    Simple php udp socket client
*/

//Reduce errors
error_reporting(~E_WARNING);

$server = '255.255.255.255';
$port = 30303;

if(!($sock = socket_create(AF_INET, SOCK_DGRAM, 0)))
{
    $errorcode = socket_last_error();
    $errormsg = socket_strerror($errorcode);

    die("Couldn't create socket: [$errorcode] $errormsg \n");
}

echo "Socket created \n";

//Communication loop
while(1)
{
    //Take some input to send
    echo 'Enter a message to send : ';
    $input = fgets(STDIN);

    //Send the message to the server
    if( ! socket_sendto($sock, $input , strlen($input) , 0 , $server , $port))
    {
        $errorcode = socket_last_error();
        $errormsg = socket_strerror($errorcode);

        die("Couldn't create socket for send: [$errorcode] $errormsg \n");
}
}

echo "Socket created \n";
Post Reply