php - Erlang Binary Packet -


I am very new to Erlang, and I'm converting some of my PHP stuff, Can not figure out the outside Here's the function in PHP:

  public function raw_send ($ string1, $ string2 = zero, $ type = SERVERDATA_EXECCOMMAND) {$ data = pack ('vv', $ this- & Gt; get_request_id (), $ type) $ string 1 chr (0) $ string 2 chr (0); // Build Data $ Packet = Pack ('V', Stellen ($ data)). $ Data; FILIT ($ this-> FP, $ packet, strollon ($ packet)); }  

This is my attempt:

  raw_send (SOK, STRING1, string2, type) - & gt; RequestId = Random: Uniforms (10), PacketData = list_to_binary ([<>, STRING1, 0, string2, 0]), DataLength = byte_size (PacketData), packet = List_to_binary ([& lt; DataLength & gt; & gt ;, PacketData]), fine = gen_tcp: to send (soak, packet).  

To compare things using CRC32, I have tried the pack ("VV", 1, 3) in php = & lt; & Lt; 1 / unsigned-little, 3 / unsigned-little >>, some

Besides, what I'm trying to do is the specs:!

Introduction

Thanks

After

is understood 32 bit integers were not used! (Thank you for @freenode)

  raw_send (SOK, STRING1, string2, type) - & gt; RequestId = Random: Uniforms (10), String1Bin = list_to_binary (STRING1), String2Bin = list_to_binary (string2), PacketData = & lt; & Lt; RequestId: 32 / bit, type: 32, / little String1Bin / binary, 0, String2Bin / binary, 0> & Gt ;, DataLength = byte_size (PacketData), packet = & lt; & Lt; DataLength: 32, / Little PacketData / Binary & gt; & Gt;, OK = gen_tcp: to send (soak, packet)  

Hope that helps anyone!


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -