Page 1 of 1

PHP buffer problem

Posted: Wed Aug 15, 2007 5:30 am
by handras
Hi,

I would like make a buffer into different type variables (int2, int4, uint2 etc.) with PHP and i will send on socket for a server application.

example:
I have variables:

Code: Select all

$this->ConnectionId = new VARIANT (-1,VT_I2);
$this->LastOpCode = new VARIANT (65535,VT_UI2);
....
I need a buffer [ConnectionId,LastOpCode,...]


I don't know how can i begin this problem.
Please, give me any idea.
Thank You in advance,

Andras

Posted: Wed Aug 15, 2007 8:38 am
by feyd
Create the VARIANT class, and the VT_* defines. :?

Posted: Thu Aug 16, 2007 3:03 am
by handras
Ok, but i need one buffer. I don't know , how can i interlacing my variables.
The server waiting only one string but i have many variables .

Sorry, but i have used general PHP command.

Please, help me ! :)

Posted: Thu Aug 16, 2007 7:44 am
by feyd
Do you understand how this "buffer" needs to be composed, data structure-wise?

Posted: Thu Aug 16, 2007 8:06 am
by superdezign
I'm not exactly sure what you are after handras, but maybe pack() and unpack() could prove useful in this VARIANT class of yours. There may be other ways to limit binary data types in PHP, but I'm not aware of them.

Maybe something like:

Code: Select all

list($this->data) = unpack("ivalue", pack("i", $value));

Posted: Tue Aug 21, 2007 9:26 am
by handras
Thanks, I can use the pack and unpack.