Lua binary networking

Trying to create network game using Corona SDK and java backend, but have some troubles with lua sockets. At first I used tcp and json data, but now remaking to udp and binary data.
How can I send custom structure to server?
For example, I need to send code of operation (short), ID (long) and two coordinates (float). I can do that with C or Java, but don’t understand how to do that with Lua, how to write it into socket? [import]uid: 181619 topic_id: 33118 reply_id: 333118[/import]

Lua doesn’t do binary very well. There are no native bitwise operators. It’s not like C based languages where you can pack an int into a character buffer and write the character buffer.

I would google around and see if someone has some lua code to do it. Look at string.byte() and string.char() to convert numeric bytes into characters.
[import]uid: 19626 topic_id: 33118 reply_id: 131518[/import]

Lua doesn’t do binary very well. There are no native bitwise operators. It’s not like C based languages where you can pack an int into a character buffer and write the character buffer.

I would google around and see if someone has some lua code to do it. Look at string.byte() and string.char() to convert numeric bytes into characters.
[import]uid: 19626 topic_id: 33118 reply_id: 131518[/import]