diff --git a/NEW b/NEW new file mode 100644 index 0000000..749641a --- /dev/null +++ b/NEW @@ -0,0 +1,5 @@ +Socket structures are independent +UDPBUFFERSIZE is now internal +Better treatment of closed connections: test!!! +HTTP post now deals with 1xx codes +connect, bind etc only try first address returned by resolver diff --git a/TODO b/TODO new file mode 100644 index 0000000..50031b1 --- /dev/null +++ b/TODO @@ -0,0 +1,38 @@ +- Inicializaccao das classes pode falhar? + +* Como mostrar um erro em lua_socketlibopen()... +* O location do "redirect" pode ser relativo ao servidor atual (não pode, + mas os servidores fazem merda...) +* - Ajeitar para Lua 4.1 + +- Padronizar os retornos de funccao +- Thread-safe + - proteger gethostby*.* com um mutex GLOBAL! + - proteger o atomizar o conjunto (timedout, receive), (timedout, send) +- Usar "require" nos módulos +- SSL +- Fazer compilar com g++ +- usar lua_verror +- separar as classes em arquivos +- criar mais uma classe, a de stream, entre p_sock e p_client +- criar um internal include file ls.h +- impedir que voe quando chamar accept(udpsocket()) +- trocar recv and send por read e write (ver se funciona) + +- checar operações em closed sockets +- checar teste de writable socket com select + +- trocar IPv4 para networking ou ipc + +- checar todos os metodos +- checar options em UDP +- checar todas as globais +- checar os metodos virtuais +- checar garbage collection + +- unix 92 bytes maximo no endereço, incluindo o zero +- unix 9216 maximo de datagram size + +- retorno de send/receive em datagram sockets pode ser refused... + +- adicionar um método sock:setoption??? diff --git a/src/luasocket.c b/src/luasocket.c index 26bc014..f6d1df7 100644 --- a/src/luasocket.c +++ b/src/luasocket.c @@ -44,11 +44,11 @@ \*-------------------------------------------------------------------------*/ LUASOCKET_API int lua_socketlibopen(lua_State *L) { + compat_open(L); priv_open(L); select_open(L); base_open(L); tm_open(L); - compat_open(L); fd_open(L); sock_open(L); inet_open(L); diff --git a/src/timeout.c b/src/timeout.c index dfece82..50a84da 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -151,9 +151,9 @@ int tm_lua_sleep(lua_State *L) { double n = luaL_checknumber(L, 1); #ifdef WIN32 - Sleep(n*1000); + Sleep((int)n*1000); #else - sleep(n); + sleep((int)n); #endif return 0; } diff --git a/src/unix.c b/src/unix.c index 0fc08bd..511a6bb 100644 --- a/src/unix.c +++ b/src/unix.c @@ -1,8 +1,6 @@ /*=========================================================================*\ * Network compatibilization module \*=========================================================================*/ -#include - #include #include @@ -17,14 +15,14 @@ static cchar *try_setbooloption(lua_State *L, COMPAT_FD sock, int name); /*=========================================================================*\ * Exported functions. \*=========================================================================*/ -void compat_open(lua_State *L) +int compat_open(lua_State *L) { - /* Instals a handler to ignore sigpipe. This function is not - needed on the WinSock2, since it's sockets don't raise signals. */ + /* Instals a handler to ignore sigpipe. */ struct sigaction new; memset(&new, 0, sizeof(new)); new.sa_handler = SIG_IGN; sigaction(SIGPIPE, &new, NULL); + return 1; } COMPAT_FD compat_accept(COMPAT_FD s, struct sockaddr *addr, @@ -59,7 +57,7 @@ int compat_send(COMPAT_FD c, cchar *data, size_t count, size_t *sent, err = PRIV_CLOSED; #ifdef __CYGWIN__ /* this is for CYGWIN, which is like Unix but has Win32 bugs */ - if (sent < 0 && errno == EWOULDBLOCK) err = PRIV_DONE; + if (errno == EWOULDBLOCK) err = PRIV_DONE; #endif *sent = 0; } else { diff --git a/src/unix.h b/src/unix.h index 944b471..5f89569 100644 --- a/src/unix.h +++ b/src/unix.h @@ -1,7 +1,5 @@ -#ifndef COMPAT_H_ -#define COMPAT_H_ - -#include "lspriv.h" +#ifndef UNIX_H_ +#define UNIX_H_ /*=========================================================================*\ * BSD include files @@ -24,46 +22,17 @@ #include /* sigpipe handling */ #include - +/* IP stuff*/ #include #include #define COMPAT_FD int #define COMPAT_INVALIDFD (-1) -/* we are lazy... */ -typedef struct sockaddr SA; - -/*=========================================================================*\ -* Exported functions -\*=========================================================================*/ -void compat_open(lua_State *L); - #define compat_bind bind #define compat_connect connect #define compat_listen listen #define compat_close close #define compat_select select -COMPAT_FD compat_socket(int domain, int type, int protocol); -COMPAT_FD compat_accept(COMPAT_FD s, SA *addr, int *len, int deadline); -int compat_send(COMPAT_FD c, cchar *data, size_t count, size_t *done, - int deadline); -int compat_recv(COMPAT_FD c, uchar *data, size_t count, size_t *done, - int deadline); -int compat_sendto(COMPAT_FD c, cchar *data, size_t count, size_t *done, - int deadline, SA *addr, int len); -int compat_recvfrom(COMPAT_FD c, uchar *data, size_t count, size_t *got, - int deadline, SA *addr, int *len); -void compat_setnonblocking(COMPAT_FD sock); -void compat_setblocking(COMPAT_FD sock); -void compat_setreuseaddr(COMPAT_FD sock); - -const char *compat_hoststrerror(void); -const char *compat_socketstrerror(void); -const char *compat_bindstrerror(void); -const char *compat_connectstrerror(void); - -cchar *compat_trysetoptions(lua_State *L, COMPAT_FD sock); - -#endif /* COMPAT_H_ */ +#endif /* UNIX_H_ */ diff --git a/test/testclnt.lua b/test/testclnt.lua index 15f1dd8..7c65823 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua @@ -13,7 +13,7 @@ function fail(...) end function warn(...) - local s = format(unpack(arg)) + local s = string.format(unpack(arg)) io.write("WARNING: ", s, "\n") end