PHP socket_recv像C ++一样返回char *

I have an sockets code written in C++... but i want to convert to PHP.

Here is the C++ code if you want to analyze.

http://pastebin.com/hzX1A8mH

My current problem is.. make socket_recv return (char*) or something like c++ code.

C++ Code..

m_MsgSize = recv(socket, (char*)m_MsgBuf, 2, 0);

And in php?

$m_MsgSize = socket_recv($socket, ???, 2, 0);

Any variable can go there, even one that has yet to be instantiatied.

eg:

$m_MsgSize = socket_recv($socket, $buffer, 2, 0);

In this case $buffer is passed to the function by reference and afterwards will contain the 2 bytes received.

Documentation: