Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page writing to socket.. operation not permitted
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
skunk-m is on a distinguished road
 
Posts: 3
Join Date: Jun 2009
Default writing to socket.. operation not permitted - 06-23-2009, 08:16 PM

hello,

i've downloaded a script for sending a magic packet to wake up my home pc.
but you need to be root to write to the socket.

so i get this:
Warning: socket_sendto() [function.socket-sendto]: unable to write to socket [1]: Operation not permitted in /home/a4652243/public_html/henks.php on line 46

here is the script:
PHP Code:
      <?
      flush
();

      function 
WakeOnLan($addr$mac$socket_number) {

        
$addr_byte explode(':'$mac);

        
$hw_addr '';

        for (
$a=0$a <6$a++) $hw_addr .= chr(hexdec($addr_byte[$a]));

        
$msg chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);

        for (
$a 1$a <= 16$a++) $msg .= $hw_addr;

        
// send it to the broadcast address using UDP

        // SQL_BROADCAST option isn't help!!

        
$s socket_create(AF_INETSOCK_DGRAMSOL_UDP);

        if (
$s == false) {

          echo 
"Error creating socket!\n";

          echo 
"Error code is '".socket_last_error($s)."' - " socket_strerror(socket_last_error($s));

          return 
FALSE;

          }

        else {

          
// setting a broadcast option to socket:

          
$opt_ret socket_set_option($s16TRUE);

          if(
$opt_ret <0) {

            echo 
"setsockopt() failed, error: " strerror($opt_ret) . "\n";

            return 
FALSE;

            }

          if(
socket_sendto($s$msgstrlen($msg), 0$addr$socket_number)) {

            echo 
"Magic Packet sent successfully!";

            
socket_close($s);

            return 
TRUE;

            }

          else {

            echo 
"Magic packet failed!";

            return 
FALSE;

            }

          }

        }

      
$socket_number "7777";

      
// MAC Address of the listening computer's network device

      
$mac_addy "my mac";

      
// IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP)

      
$ip_addy gethostbyname("my ip");

      
WakeOnLan($ip_addy$mac_addy$socket_number);
?>
is it possible to make this work?

skunk-m
Reply With Quote
(#2 (permalink))
Old
Bad Karma[CORE]'s Avatar
Direct Admin
Bad Karma[CORE] is on a distinguished road
 
Posts: 5,924
Join Date: May 2008
Default 06-23-2009, 08:44 PM

due to serverside restrictions and disabled functions -> no
Reply With Quote
(#3 (permalink))
Old
Banned
Vazzer is on a distinguished road
 
Posts: 157
Join Date: May 2009
Location: Pennsylvania.
Send a message via AIM to Vazzer Send a message via MSN to Vazzer
Default 06-24-2009, 03:04 AM

What exactly does this script do? Turns your computer on?
Reply With Quote
(#4 (permalink))
Old
Bad Karma[CORE]'s Avatar
Direct Admin
Bad Karma[CORE] is on a distinguished road
 
Posts: 5,924
Join Date: May 2008
Default 06-24-2009, 04:52 AM

either turn it on or bring it out of stand by
Reply With Quote
(#5 (permalink))
Old
Member
leegao is on a distinguished road
 
Posts: 34
Join Date: Sep 2008
Default 06-24-2009, 05:46 AM

Out of curiosity, why are you using a push technique when yuo're better suited with a polling technique. Have your home PC poll a website every x seconds and then use the webserver as the response, not the other way around.
Reply With Quote
(#6 (permalink))
Old
Junior Member
skunk-m is on a distinguished road
 
Posts: 3
Join Date: Jun 2009
Default 06-24-2009, 09:56 PM

Quote:
Originally Posted by leegao View Post
Out of curiosity, why are you using a push technique when yuo're better suited with a polling technique. Have your home PC poll a website every x seconds and then use the webserver as the response, not the other way around.
:S
my home pc is powered off.. with the script i sent te magic packet to my external ip on a specific port which i have forwarded to my broadcast adres and then the computer boots.
Reply With Quote
(#7 (permalink))
Old
Member
leegao is on a distinguished road
 
Posts: 34
Join Date: Sep 2008
Default 06-25-2009, 12:18 AM

so then I'm even more baffled. Turning on sockets wouldn't actually do anything for you. The nature of a broadcast server is that it needs to either have a indefinite executiontime (which apache does not support) or that it needs to be forked or daemonized from the apache thread so it can consume as much resource as it need for as long as it needs to.
Reply With Quote
(#8 (permalink))
Old
Junior Member
skunk-m is on a distinguished road
 
Posts: 3
Join Date: Jun 2009
Default 06-27-2009, 05:08 PM

Quote:
Originally Posted by leegao View Post
so then I'm even more baffled. Turning on sockets wouldn't actually do anything for you. The nature of a broadcast server is that it needs to either have a indefinite executiontime (which apache does not support) or that it needs to be forked or daemonized from the apache thread so it can consume as much resource as it need for as long as it needs to.
the script just creates a magic packet with the pc's mac adress and sents that to my external ip on a specific port my router forwards that port to my broadcast adress
Reply With Quote
(#9 (permalink))
Old
Member
leegao is on a distinguished road
 
Posts: 34
Join Date: Sep 2008
Default 06-28-2009, 01:55 AM

let me rephrase what I've just said. Apache's php-handler in most webhosts has the keep-alive settings off. This is why there's no plausible way of writing a comet (push) server on a free hosting since the only option would be to use longpoll. Since the client in your case makes absolutely no requests and expects it to be on the receiving end of the connection node, longpoll can not work, there's no way to create a script in php designed for a shared-configured apache server to broadcast scheduled network packets.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com