Few extra changes.

This commit is contained in:
Diego Nehab 2004-06-22 04:49:57 +00:00
parent bce1cb30d8
commit 7195ab620b
7 changed files with 11 additions and 16 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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)