Jump to content

[SOLVED] socket_connect: permission denied


govtcheeze

Recommended Posts

I have a socket listener up and running. From inside flash I can send the message "/SERVER  hi test" and it gets broadcast.

I have a test file:

[code]<?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"); }

}

?>[/code]

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 [code=php:0]serverMessage("/SERVER test message"); [/code] 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]
[color=red][b]2007-01-04 23:26:26 -- results: [Permission denied][/b][/color]
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.

I have also tried to call a test file that sets posix_userid to a user and does a shell execute of the above file. When I run that from shell it works fine, but when I run from a web browser the posix_setui() returned error is "Operation not permitted".

Help please :D
Link to comment
https://forums.phpfreaks.com/topic/32992-solved-socket_connect-permission-denied/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.