\ I have installed php 5.4.13 on Linux 2.6.34. I have make simple client/server page using socket but it did not work on it. It give permission denied error Below is my php code if (false == ($socket = socket_create(AF_INET, SOCK_STREAM, 0))) // create socket
{
$stringData= date("D M d, Y g:i A"). " socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
}
else
{
$timeout = array('sec'=>5,'usec'=>500000);
socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,$timeout);
if(false==($result = socket_connect($socket, $host, $port)))
{
$stringData= date("D M d, Y g:i A"). " socket_connect() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
socket_close($socket);
}
else
{
$stringData= date("D M d, Y g:i A"). " Socket connected succefully <br>";
echo $stringData;
if(false==(socket_write($socket, $command, strlen($command))))
{
$stringData= date("D M d, Y g:i A"). " socket_write() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
socket_close($socket);
}
else
{
if(false===($cmd = socket_read ($socket, 65536)))
{
//10060 for windows and 11 for linux
if(10060!=socket_last_error() && 11!=socket_last_error())
{
$stringData= date("D M d, Y g:i A"). " socket_read() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
socket_close($socket);
}
switch(socket_select($r = array($socket), $w = array($socket), $f = array($socket), 5))
{
case 2:
$refused=1;
break;
}
if($refused==1)
{
$stringData= date("D M d, Y g:i A"). " socket_read() failed: reason: Connection Refused <br>";
$ourFileHandle = fopen(SOCKET_LOG, 'a');
echo $stringData;
socket_close($socket);
}
}
else
{
echo "<pre>".html_entity_decode(print_r($cmd,true))."</pre>";
}
}
}
}
Above code work fine on command prompt but it gives error Permission denied when page open from any browser.
Command of run php from terminal : /usr/local/rootfs/php5/bin/php /www/socket_client.php
I have found something new related to user permission which can not allow to create socket from web interface. I can run php process from command promt with root user and can able to create socket successfully without any failure cases.
can any one have idea how to solve above issue without SElinux support because i don't have SElinux support in my system?
Please let me know as soon as possible because its a cusial issue for me to solve and also i have tried with all its possble test-cases regarding permission of php.ini,httpd.conf and whole apache folder to root user permission with 777 but still i can not create soclet while from php file wihle running php file on web interface.
I can only create that socket only on command prompt with root user login access. I can not create socket with not-root user.
I have also tried to changed root and group in httpd.conf file but still it fails to start httpd process with root user.
so is there anyone have idea about what to do with this issue?