I am going to send a byte array through socket.But I used to work in c/c++ and be new to lua. Now i have a problem,here is my question.
i want to send a bytearray.It should contain mac_address,string_length,string.
For detail:
mac_address:6 bytes length of string: 1 byte string:several bytes
(1)first question Now,I have a string of mac_address like“01:2f:c2:5e:b6:a3”,how can I convert it into a 6 byte hex array?
(2)second how to define an unsigned number and store it to byte?for example,sting_length is 33,how can i store it as 0x21 into a byte?
(3)last how to combine mac_address(6bits),string_length(1bit),data_string(for example,100bytes) into a byte array,and successfully send it out through luasocket.
that's all.
Thank you!
Aucun commentaire:
Enregistrer un commentaire