lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

(I hope it's ok to ask luasocket questions here.)

I'm using luasocket-2.0-beta3.  I've got it running fine with the lua
command-line interpreter and now I'm trying to use luasocket as a
dynamic library, loadable at run time from C code that runs lua

I see that the file luasocket.h has the following prototype:
LUASOCKET_API int luaopen_socket(lua_State *L);
but luasocket.c has the function defined as:
LUASOCKET_API int luaopen_lsocket(lua_State *L) {...}

I also see in luasocket.c that luaopen_lsocket calls base_open which
sets the module name as "socket",  like this:
luaL_module(L, "socket", func, 0);

As well, socket.lua defines itself as a module with the name "socket", ie:
local socket = require("lsocket")

So my question is: Which one is correct: luaopen_socket or
luaopen_lsocket?  (It appears, from socket.lua that it is intended to
be luaopen_lsocket.  But if that is the case, then should luasocket.c
not be setting its module name to "lsocket", ie,
'luaL_module(L, "lsocket", func, 0);'?  As you see, I'm getting myself

The files mime.h and mime.c follow the same pattern: mime.h has:
MIME_API int luaopen_mime(lua_State *L);
whereas mime.c has:
MIME_API int luaopen_lmime(lua_State *L) {
luaL_module(L, "mime", func, 0);

Thanks in advance,