public static Value socket_read(Env env,
@NotNull SocketInputOutput socket,
int length, @Optional int type)
{
TempBuffer tempBuffer = null;
TempCharBuffer tempCharBuffer = null;
try {
if (type == PHP_NORMAL_READ) {
return socket.readLine(length);
} else {
tempBuffer = TempBuffer.allocate();
if (length > tempBuffer.getCapacity())
length = tempBuffer.getCapacity();
byte []buffer = tempBuffer.getBuffer();
length = socket.read(buffer, 0, length);
if (length > 0) {
StringValue sb = env.createBinaryBuilder(buffer, 0, length);