PHP-Fusion
v.7.01
AP-Fusion
v7.02.05
Pimped-Fusion-AP
v0.09.03
April 20 2024 11:56:18
Авторизация
Логин

Пароль



Вы не зарегистрированы?
Нажмите здесь для регистрации.

Забыли пароль?
Запросите новый здесь.
Мини-чат
Вы должны авторизироваться, чтобы добавить сообщение.

lom
06/04/2018 14:03
Мы рады, ждем девятку. Очень хочется пощупать

Alipapa
27/03/2018 22:16
Всем привет, все неисправности устранили, всё у нас работает

mukaton
30/10/2015 02:37
Не получается ничего скачать. Ошибка Not Found

Alipapa
06/10/2015 23:00
9-я версия php-fusion на подходе, следите за новостями

Alipapa
10/11/2014 11:24
Заметь, я дважды ответил через 3 минуты после вопроса, могли бы уже решить

Последние статьи
· О стабилизаторах нап...
· СМС и Вебмани
· TinyMCE для пользова...
· PCRE (Perl Compatibl...
· PCRE (Perl Compatibl...
Последние активные темы форума
  Темы Просмотров Ответов Последние сообщения
PHP-Fusion 7 Bogatyr - бесп...
Моды, плагины
7133 1 Vveb--ws
08-10-2018 16:47
Php-Fusion v9. Первые впеча...
Вопросы по работе
4509 3 Vveb--ws
25-07-2018 13:46
Появился хэлп по PHP-Fusion...
Вопросы по работе
6736 7 Vveb--ws
25-07-2018 13:42
prestashop&ap-fusion
Вопросы по работе
17345 61 Alipapa
26-08-2014 10:29
Плагин магазина Ap-Shop
Моды, плагины
14586 70 Alipapa
18-08-2014 18:14
TinyMCE
Вопросы по работе
21106 55 Alipapa
27-07-2013 21:57
HTML-5
Моды, плагины
5431 1 Alipapa
15-06-2013 19:47
Мультиязычность в Pimped-Fu...
Ошибки, баги, глюки
6259 4 Papich
16-04-2013 12:39
Pimped-Fusion. Первые впеча...
Ошибки, баги, глюки
21700 127 Alipapa
18-12-2012 10:59
Ищу мод для расстановки код...
Моды, плагины
15003 55 Alipapa
17-09-2012 14:00
Как присоединить файл к лич...
Моды, плагины
8259 3 lom
27-05-2012 18:12
Что мне не нравится в после...
Вопросы по работе
6847 4 Alipapa
27-05-2012 18:08
Проблемы с добавлением кате...
Вопросы по работе
7742 5 Alipapa
27-05-2012 18:06

socket_select

(PHP 4 >= 4.1.0, PHP 5)

socket_select --  Runs the select() system call on the given arrays of sockets with a specified timeout

Description

int socket_select ( array &read, array &write, array &except, int tv_sec [, int tv_usec] )

socket_select() accepts arrays of sockets and waits for them to change status. Those coming with BSD sockets background will recognize that those socket resource arrays are in fact the so-called file descriptor sets. Three independent arrays of socket resources are watched.

The sockets listed in the read array will be watched to see if characters become available for reading (more precisely, to see if a read will not block - in particular, a socket resource is also ready on end-of-file, in which case a socket_read() will return a zero length string).

The sockets listed in the write array will be watched to see if a write will not block.

The sockets listed in the except array will be watched for exceptions.

Внимание

On exit, the arrays are modified to indicate which socket resource actually changed status.

You do not need to pass every array to socket_select(). You can leave it out and use an empty array or NULL instead. Also do not forget that those arrays are passed by reference and will be modified after socket_select() returns.

Пример 1. socket_select() example

<?php
/* Prepare the read array */
$read = array( $socket1 , $socket2 );

$num_changed_sockets = socket_select ( $read , $write = NULL , $except = NULL , 0 );

if (
$num_changed_sockets === false ) {
    
/* Error handling */
} else if ( $num_changed_sockets > 0 ) {
    
/* At least at one of the sockets something interesting happened */
}
?>

Замечание: Due a limitation in the current Zend Engine it is not possible to pass a constant modifier like NULL directly as a parameter to a function which expects this parameter to be passed by reference. Instead use a temporary variable or an expression with the leftmost member being a temporary variable:

Пример 2. Using NULL with socket_select()

<?php
socket_select
( $r , $w , $e = NULL , 0 );
?>

The tv_sec and tv_usec together form the timeout parameter. The timeout is an upper bound on the amount of time elapsed before socket_select() return. tv_sec may be zero , causing socket_select() to return immediately. This is useful for polling. If tv_sec is NULL (no timeout), socket_select() can block indefinitely.

On success socket_select() returns the number of socket resources contained in the modified arrays, which may be zero if the timeout expires before anything interesting happens. On error FALSE is returned. The error code can be retrieved with socket_last_error().

Замечание: Be sure to use the === operator when checking for an error. Since the socket_select() may return 0 the comparison with == would evaluate to TRUE:

Пример 3. Understanding socket_select()'s result

<?php
if ( false === socket_select ( $r , $w , $e = NULL , 0 )) {
    echo
"socket_select() failed, reason: " .
        
socket_strerror ( socket_last_error ()) . "\n" ;
}
?>

Замечание: Be aware that some socket implementations need to be handled very carefully. A few basic rules:

  • You should always try to use socket_select() without timeout. Your program should have nothing to do if there is no data available. Code that depends on timeouts is not usually portable and difficult to debug.

  • No socket resource must be added to any set if you do not intend to check its result after the socket_select() call, and respond appropriately. After socket_select() returns, all socket resources in all arrays must be checked. Any socket resource that is available for writing must be written to, and any socket resource available for reading must be read from.

  • If you read/write to a socket returns in the arrays be aware that they do not necessarily read/write the full amount of data you have requested. Be prepared to even only be able to read/write a single byte.

  • It's common to most socket implementations that the only exception caught with the except array is out-of-bound data received on a socket.

Смотрите также socket_read(), socket_write(), socket_last_error() and socket_strerror().

Все функции PHP:
Навигация
· Новости
· Статьи
· Скачать
· Форум
· Ссылки
· Категории новостей
· Обратная связь
· Галерея
· Поиск
· CMS AP-Fusion. Отличия от PHP-Fusion
· Javascript справочник
· Техника
Сейчас на сайте
· Гостей: 2

· Пользователей: 0

· Всего пользователей: 453
· Новый пользователь: ZDA
Информеры
Загрузка файлов  +  -
9,938,999 уникальных посетителей Iceberg by Harly