mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 06:18:21 +01:00
Few extra changes.
This commit is contained in:
parent
bce1cb30d8
commit
7195ab620b
@ -25,10 +25,6 @@
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Initializes the library.
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#ifndef LUASOCKET_LIBNAME
|
||||
#define LUASOCKET_LIBNAME "socket"
|
||||
#endif
|
||||
|
||||
LUASOCKET_API int luaopen_socket(lua_State *L);
|
||||
|
||||
#endif /* LUASOCKET_H */
|
||||
|
@ -19,10 +19,6 @@
|
||||
#define MIME_API extern
|
||||
#endif
|
||||
|
||||
#ifndef MIME_LIBNAME
|
||||
#define MIME_LIBNAME "mime"
|
||||
#endif
|
||||
|
||||
MIME_API int luaopen_mime(lua_State *L);
|
||||
|
||||
#endif /* MIME_H */
|
||||
|
@ -106,7 +106,10 @@ function open(server, port)
|
||||
local tp = socket.try(tp.connect(server or SERVER, port or PORT, TIMEOUT))
|
||||
local s = setmetatable({tp = tp}, metat)
|
||||
-- make sure tp is closed if we get an exception
|
||||
s.try = socket.newtry(function() s:close() end)
|
||||
s.try = socket.newtry(function()
|
||||
if s.tp:command("QUIT") then s.tp:check("2..") end
|
||||
s:close()
|
||||
end)
|
||||
return s
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,6 @@ function socket.bind(host, port, backlog)
|
||||
sock:setoption("reuseaddr", true)
|
||||
local res, err = sock:bind(host, port)
|
||||
if not res then return nil, err end
|
||||
backlog = backlog or 32
|
||||
res, err = sock:listen(backlog)
|
||||
if not res then return nil, err end
|
||||
return sock
|
||||
|
@ -232,7 +232,7 @@ static int meth_close(lua_State *L)
|
||||
static int meth_listen(lua_State *L)
|
||||
{
|
||||
p_tcp tcp = (p_tcp) aux_checkclass(L, "tcp{master}", 1);
|
||||
int backlog = (int) luaL_checknumber(L, 2);
|
||||
int backlog = (int) luaL_optnumber(L, 2, 32);
|
||||
const char *err = sock_listen(&tcp->sock, backlog);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
|
@ -136,8 +136,7 @@ int tm_gettime(void)
|
||||
int tm_gettime(void)
|
||||
{
|
||||
struct timeval v;
|
||||
struct timezone z = {0, 0};
|
||||
gettimeofday(&v, &z);
|
||||
gettimeofday(&v, (struct timezone *) NULL);
|
||||
return v.tv_sec * 1000 + v.tv_usec/1000;
|
||||
}
|
||||
#endif
|
||||
|
@ -50,9 +50,11 @@ source = smtp.message{
|
||||
|
||||
-- finally send it
|
||||
r, e = smtp.send{
|
||||
rcpt = "<fulano@tecgraf.puc-rio.br>",
|
||||
from = "<sicrano@tecgraf.puc-rio.br>",
|
||||
source = source
|
||||
rcpt = {"<diego@tecgraf.puc-rio.br>",
|
||||
"<diego@princeton.edu>" },
|
||||
from = "<diego@princeton.edu>",
|
||||
source = source,
|
||||
server = "mail.cs.princeton.edu"
|
||||
}
|
||||
|
||||
print(r, e)
|
||||
|
Loading…
Reference in New Issue
Block a user