Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7850199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:46:48+00:00 2026-06-02T18:46:48+00:00

In the php documentation listed here there’s an indication that the function uses the

  • 0

In the php documentation listed here there’s an indication that the function uses the read, error and write array values as refference but I have failed to find anywhere what is actually changed in those values.

I wrote a simple ‘server’ I use now and I noted that when the mentioned function fails to see any data on the polled clients, then it changes the array and renders it unusable to poll again. This is my code:

<php - all socket creation binding and listening above..
socket_set_nonblock($mysock);

$w = $e = array();
$clients = array($mysock);

do {
    $temp_client = @socket_accept($mysock);
    if ($temp_client != FALSE) 
        $clients[] = $temp_client;

    $clients_backup = $clients;

    $select_socket = socket_select($clients,$w,$e,0);
    if (($select_socket !== FALSE) AND ($select_socket != 0)) {
        foreach ($clients as $value) {
            $input = socket_read($value,1024,PHP_BINARY_READ);
            echo $input;
        }
    }
    $clients = $clients_backup;
} while(TRUE);

When testing this consider that the first connection is not handled.. I have no idea why (would very much thank elightment) this code is a strip of what I’m developing and there it works ok. The socket_select issue remains the same in both codes.

Basically If I do not make that backup of the clients array, it doesn’t work. The error: “no resource arrays were passed to select” is seen since the array doesn’t have the socket resource after socket_select first checks a connection with no data to read.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:46:49+00:00Added an answer on June 2, 2026 at 6:46 pm

    These arrays are arrays of socket resources. socket_select() will modify the arrays by removing from them any resources that aren’t ready to be read from, written to, etc., respectively.

    You’ll almost always want to pass it copies of your arrays, because they will be modified, and you don’t want to lose your original references to them:

    $clients = [ ... ];
    $r = $w = $e = $clients;
    
    $numChanged = socket_select($r, $w, $e, ...);
    
    // Here, $r, $w, and $e will only contain the resources that are ready for processing, which may be none at all
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The PHP documentation states that php://input can only be read once. In my application
There is a function similar_text() in the PHP library. The documentation ( http://php.net/manual/en/function.similar-text.php )
Official PHP documentation states that filter_var_array() supports array filtering in the following format: $data
PHP's documentation for the proc_open function states that when spawning a child process, you
I read from the php documentation that since 5.1.0 scandir() is by default not
The PHP documentation can be found here , but I think it's rather lacking.
I've read through the Google Spreadsheets API PHP documentation. All examples are using Zend,
The documentation here is not very clear: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=editurl#saverow Do I have to manually make
According to the PHP Documentation PDO::prepare() adds quotes to all your parameters so that
Looking at the php documentation on setting a cookie I see that I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.