Find the answer to your Linux question:
Results 1 to 2 of 2
hi friends, 1. I hv done a simple client application in php to send "hello world" to the port 1234 in 127.0.0.1 (localhost). (google in net for php client program) ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    30

    Lightbulb permission denied error in php socket programming

    hi friends,
    1. I hv done a simple client application in php to send "hello world" to the port 1234 in 127.0.0.1 (localhost).
    (google in net for php client program)
    2. opened terminal and
    $nc -l 1234

    so that whatever comes in port 1234 i will get it from the terminal.

    1. socket successfully created.
    2. Attempting to connect to '127.0.0.1' on port '1234'...socket_connect() failed. Reason: () Permission denied
    3. if i run in terminal,
    $php client.php
    No issues, it is communicating.
    if i access the same with browser (firefox) it is giving problem.

    Error in :
    echo "Attempting to connect to '$address' on port '$port'...";
    $result = socket_connect($socket, $address, $port);
    if ($result === false) {
    echo "socket_connect() failed.\nReason: ($result) ";
    echo "\n". socket_strerror(socket_last_error($socket)) . "\n";
    } else {
    echo "successfully connected to $address.\n";
    }

    can some one help me to resolve the issue

  2. #2
    Just Joined!
    Join Date
    Oct 2008
    Posts
    30

    Lightbulb

    Problem solved:
    type
    $/usr/sbin/setsebool httpd_can_network_connect=1

    Now it works fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...