I knew this would come up

I actually didn't make my mind yet about sockets:
- functions to use, it's not only about availability on most hosts but also behaviours on different OSes
- blocking/non-blocking, though blocking should be best
- timeout, my loop is actually countering it, which is why it's less clean but I could have written the following
Code: Select all
$data = fread($this->socket, $size);
if(strlen($data) < $size || $data === false)
throw new TransportException('Connection interrupted while reading data', TransportException::INTERRUPTED);
However, supporting shared hosts is important too. Even if this library is mostly used in server controllers, it's aimed to be useful for websites too like the DedicatedManager or anything else.
About xmlrpc extension, I was actually thinking about checking if the extension is loaded to use it in priority so everyone would be happy ^^ It's obviously way faster than my solution, but I wanted a better alternative than the current one. I compared the 3 with both a small and a large request and here are the average on 1000 executions each:
Code: Select all
| current | mine | xmlrpc
--------------------------------------------
decode (small) | 0.234ms | 0.052ms | 0.019ms
encode (small) | 0.035ms | 0.019ms | 0.011ms
--------------------------------------------
decode (large) | 4.117ms | 0.902ms | 0.183ms
encode (large) | 1.403ms | 0.658ms | 0.097ms
Though I cannot reach the speed of C with pure PHP, I'm still proud of the improvement compared to the current solution
