Blocking vs. Selecting
| From: | René Fournier | Date: | Thu, 20 May 2004 21:18:53 +0000 |
| Subject: | Blocking vs. Selecting | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-186628@lists.php.net to get a copy of this message | ||
MY PROGRAM FLOW:
Enter loop
Wait incoming data
If (incoming data) {
do something
} elseif (no data && delay > 5 seconds) {
send ping to server
return to top of loop
}
Of course, it's very simple. :-) But to make it work, I think I need to choose:
1. Timeout the socket_read() (nonblocking socket, etc.)
or
2. Use socket_select.
Here's my question: I have only one socket active in this application at any time. Is it appropriate to use socket_select with just one socket connection? And if I stop deselect that socket, and the server sends data while the scirpt is doing something else, will the data be lost, or will it wait o be read again once the script can give its attention to that connection?
....rEne