Maison >développement back-end >tutoriel php >socket_select(), 请大神讲授
socket_select(), 请大神讲解
请大神帮忙解释一下 socket_select() 这个函数的作用,看php手册大致意思是阻塞的意思,请问什么情况下阻塞,什么时候继续往下执行啊,参数如下
<br />int socket_select ( array &$read , array &$write , array &$except , int $tv_sec [, int $tv_usec = 0 ] );<br /><br />//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.<br /><br />//param<br /><br />/*<br />read<br />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).<br /><br />write<br />The sockets listed in the write array will be watched to see if a write will not block.<br /><br />except<br />The sockets listed in the except array will be watched for exceptions.<br /><br />tv_sec<br />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.<br />*/<br />