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