c# - Php Byte Array Packet -


i have c# library practically starts listening on tcpip server accepts buffer of size.

i need send packet byte array php on socket in form of byte array or equivalent.

the packet constructed example byte[1] (a flag) number 0 255 , byte[6] byte[11] contains float number in string fromat example: 005.70 takes 6 bytes representing every character.

i managed send flag when try send float number not convert on other side (c#).

so question how can send byte array c# using php?

from c# part conversion being handled follows:

float.parse(system.text.encoding.default.getstring(data, 6, 6)); 

just after have posted question have dictated answer. not 100% sure if right way managed convert correctly.

here answer:

i created array of characters , escaped flag (4) actual byte value being (4) didn't escape money value

$string = array (0=>"\0", 1=>"\4", 2=>"\0", 3=>"\0", 4=>"\0", 5=>"\0", 6=>"5", 7=>".", 8=>"7", 9=>"\0", 10=>"\0"); 

imploded nothing glue:

$arrbyte =  implode("", $string); 

and sent on opened socket:

$success = @fwrite($this->socket, $arrbyte); 

Comments