How do I pass binary data to a c dll from lua?
Well, it depends... The binary data could be represented as a string,
a full userdata, or even a full / light userdata containing a pointer
to your (externally allocated) data.
I retrieve the value in c by using "arg1 = luaL_checklstring(L, 1, &len);",
but than it says "string expected, got userdata".
>From th error message, I guess you are storing your binary data in a
(full?) userdata, but you tried the string function for retrieval. It
won't work.
You should instead use lua_touserdata to retrieve the pointer to the
data, and lua_objlen (5.1) / lua_rawlen (5.2) to get the length in
bytes.