govtcheeze
January 5th, 2007, 12:12 PM
I have a socket listener up and running (it's from the flash/php tutorial on this site), which works fine with flash.
I have a test file:
<?php
serverMessage("/SERVER test message");
function serverMessage($buf) {
if(DEBUG_HASH) { logDebug("entering function <b>serverMessage</b> in sockTest.php: buf: [$buf]"); }
$ip = "myIP"; // my real IP is in the file
$port = myPort; // my real port is in the file
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if(DEBUG_HASH) { logDebug("socket: [$socket]"); }
//socket_set_nonblock($socket);
socket_connect($socket, $ip, $port);
if(DEBUG_HASH) { logDebug("results: [" . socket_strerror(socket_last_error()) . "]"); }
//socket_set_block($socket);
$results = socket_write($socket, $buf);
if(DEBUG_HASH) { logDebug("results: [" . socket_strerror(socket_last_error()) . "]"); }
socket_shutdown($socket, 2);
socket_close($socket);
if(DEBUG_HASH) { logDebug("exiting function serverMessage"); }
}
?>
When I run it from shell, it parses the message and outputs to proper text to connected users.
When I call this function from within a php file that runs as a web page
serverMessage("/SERVER test message"); I get the following error log (bolded red is the permission issue):
2007-01-04 23:26:26 -- entering function serverMessage in sockTest.php: buf: [/SERVER test message]
2007-01-04 23:26:26 -- socket: [Resource id #42]
2007-01-04 23:26:26 -- results: [Permission denied]
2007-01-04 23:26:26 -- results: [Broken pipe]
2007-01-04 23:26:26 -- exiting function serverMessage
Any ideas why I can't connect from within the web based PHP script but I Can when connected to shell? Looks like some sort of perm issue, but many searches on google turned up no data I found to help resolve this issue.
Help ! :D
I have a test file:
<?php
serverMessage("/SERVER test message");
function serverMessage($buf) {
if(DEBUG_HASH) { logDebug("entering function <b>serverMessage</b> in sockTest.php: buf: [$buf]"); }
$ip = "myIP"; // my real IP is in the file
$port = myPort; // my real port is in the file
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if(DEBUG_HASH) { logDebug("socket: [$socket]"); }
//socket_set_nonblock($socket);
socket_connect($socket, $ip, $port);
if(DEBUG_HASH) { logDebug("results: [" . socket_strerror(socket_last_error()) . "]"); }
//socket_set_block($socket);
$results = socket_write($socket, $buf);
if(DEBUG_HASH) { logDebug("results: [" . socket_strerror(socket_last_error()) . "]"); }
socket_shutdown($socket, 2);
socket_close($socket);
if(DEBUG_HASH) { logDebug("exiting function serverMessage"); }
}
?>
When I run it from shell, it parses the message and outputs to proper text to connected users.
When I call this function from within a php file that runs as a web page
serverMessage("/SERVER test message"); I get the following error log (bolded red is the permission issue):
2007-01-04 23:26:26 -- entering function serverMessage in sockTest.php: buf: [/SERVER test message]
2007-01-04 23:26:26 -- socket: [Resource id #42]
2007-01-04 23:26:26 -- results: [Permission denied]
2007-01-04 23:26:26 -- results: [Broken pipe]
2007-01-04 23:26:26 -- exiting function serverMessage
Any ideas why I can't connect from within the web based PHP script but I Can when connected to shell? Looks like some sort of perm issue, but many searches on google turned up no data I found to help resolve this issue.
Help ! :D