PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm working on PHP MSN bot. When I create new switchboard, i create new proccess. I want to comunicate with these two processes. In switchboard proccess I create socket and authorize and then I use while(TRUE).
I try socket_select, but it doesn't work. I use fsockopen for opening socket. When I select sockets between stdin socket and msn socket in gives me error.
array(2) {
[0]=>
resource(7) of type (stream)
[1]=>
resource(9) of type (stream)
}
Warning: socket_select(): supplied resource is not a valid Socket resource in /path/to/script/msn_sb.php on line 57
Warning: socket_select(): no resource arrays were passed to select in /path/to/script/msn_sb.php on line 57
OK, I made it with stream_select, but this is not what I want. This function looks if there's any opend sockets and put them into array. I need something to watch sockets for data and when there is some data, it return which socket contains data.
Create the "msn" socket with the socket_* family of functions.
On second thought, stream_select *is* what you need. How are you calling it?
RTFM wrote:The streams 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 stream resource is also ready on end-of-file, in which case an fread() will return a zero length string).