aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEW5
-rw-r--r--TODO38
-rw-r--r--src/luasocket.c2
-rw-r--r--src/timeout.c4
-rw-r--r--src/unix.c10
-rw-r--r--src/unix.h39
-rw-r--r--test/testclnt.lua2
7 files changed, 55 insertions, 45 deletions
diff --git a/NEW b/NEW
new file mode 100644
index 0000000..749641a
--- /dev/null
+++ b/NEW
@@ -0,0 +1,5 @@
1Socket structures are independent
2UDPBUFFERSIZE is now internal
3Better treatment of closed connections: test!!!
4HTTP post now deals with 1xx codes
5connect, 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 @@
1- Inicializaccao das classes pode falhar?
2
3* Como mostrar um erro em lua_socketlibopen()...
4* O location do "redirect" pode ser relativo ao servidor atual (não pode,
5 mas os servidores fazem merda...)
6* - Ajeitar para Lua 4.1
7
8- Padronizar os retornos de funccao
9- Thread-safe
10 - proteger gethostby*.* com um mutex GLOBAL!
11 - proteger o atomizar o conjunto (timedout, receive), (timedout, send)
12- Usar "require" nos módulos
13- SSL
14- Fazer compilar com g++
15- usar lua_verror
16- separar as classes em arquivos
17- criar mais uma classe, a de stream, entre p_sock e p_client
18- criar um internal include file ls.h
19- impedir que voe quando chamar accept(udpsocket())
20- trocar recv and send por read e write (ver se funciona)
21
22- checar operações em closed sockets
23- checar teste de writable socket com select
24
25- trocar IPv4 para networking ou ipc
26
27- checar todos os metodos
28- checar options em UDP
29- checar todas as globais
30- checar os metodos virtuais
31- checar garbage collection
32
33- unix 92 bytes maximo no endereço, incluindo o zero
34- unix 9216 maximo de datagram size
35
36- retorno de send/receive em datagram sockets pode ser refused...
37
38- 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 @@
44\*-------------------------------------------------------------------------*/ 44\*-------------------------------------------------------------------------*/
45LUASOCKET_API int lua_socketlibopen(lua_State *L) 45LUASOCKET_API int lua_socketlibopen(lua_State *L)
46{ 46{
47 compat_open(L);
47 priv_open(L); 48 priv_open(L);
48 select_open(L); 49 select_open(L);
49 base_open(L); 50 base_open(L);
50 tm_open(L); 51 tm_open(L);
51 compat_open(L);
52 fd_open(L); 52 fd_open(L);
53 sock_open(L); 53 sock_open(L);
54 inet_open(L); 54 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)
151{ 151{
152 double n = luaL_checknumber(L, 1); 152 double n = luaL_checknumber(L, 1);
153#ifdef WIN32 153#ifdef WIN32
154 Sleep(n*1000); 154 Sleep((int)n*1000);
155#else 155#else
156 sleep(n); 156 sleep((int)n);
157#endif 157#endif
158 return 0; 158 return 0;
159} 159}
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 @@
1/*=========================================================================*\ 1/*=========================================================================*\
2* Network compatibilization module 2* Network compatibilization module
3\*=========================================================================*/ 3\*=========================================================================*/
4#include <string.h>
5
6#include <lua.h> 4#include <lua.h>
7#include <lauxlib.h> 5#include <lauxlib.h>
8 6
@@ -17,14 +15,14 @@ static cchar *try_setbooloption(lua_State *L, COMPAT_FD sock, int name);
17/*=========================================================================*\ 15/*=========================================================================*\
18* Exported functions. 16* Exported functions.
19\*=========================================================================*/ 17\*=========================================================================*/
20void compat_open(lua_State *L) 18int compat_open(lua_State *L)
21{ 19{
22 /* Instals a handler to ignore sigpipe. This function is not 20 /* Instals a handler to ignore sigpipe. */
23 needed on the WinSock2, since it's sockets don't raise signals. */
24 struct sigaction new; 21 struct sigaction new;
25 memset(&new, 0, sizeof(new)); 22 memset(&new, 0, sizeof(new));
26 new.sa_handler = SIG_IGN; 23 new.sa_handler = SIG_IGN;
27 sigaction(SIGPIPE, &new, NULL); 24 sigaction(SIGPIPE, &new, NULL);
25 return 1;
28} 26}
29 27
30COMPAT_FD compat_accept(COMPAT_FD s, struct sockaddr *addr, 28COMPAT_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,
59 err = PRIV_CLOSED; 57 err = PRIV_CLOSED;
60#ifdef __CYGWIN__ 58#ifdef __CYGWIN__
61 /* this is for CYGWIN, which is like Unix but has Win32 bugs */ 59 /* this is for CYGWIN, which is like Unix but has Win32 bugs */
62 if (sent < 0 && errno == EWOULDBLOCK) err = PRIV_DONE; 60 if (errno == EWOULDBLOCK) err = PRIV_DONE;
63#endif 61#endif
64 *sent = 0; 62 *sent = 0;
65 } else { 63 } 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 @@
1#ifndef COMPAT_H_ 1#ifndef UNIX_H_
2#define COMPAT_H_ 2#define UNIX_H_
3
4#include "lspriv.h"
5 3
6/*=========================================================================*\ 4/*=========================================================================*\
7* BSD include files 5* BSD include files
@@ -24,46 +22,17 @@
24#include <netdb.h> 22#include <netdb.h>
25/* sigpipe handling */ 23/* sigpipe handling */
26#include <signal.h> 24#include <signal.h>
27 25/* IP stuff*/
28#include <netinet/in.h> 26#include <netinet/in.h>
29#include <arpa/inet.h> 27#include <arpa/inet.h>
30 28
31#define COMPAT_FD int 29#define COMPAT_FD int
32#define COMPAT_INVALIDFD (-1) 30#define COMPAT_INVALIDFD (-1)
33 31
34/* we are lazy... */
35typedef struct sockaddr SA;
36
37/*=========================================================================*\
38* Exported functions
39\*=========================================================================*/
40void compat_open(lua_State *L);
41
42#define compat_bind bind 32#define compat_bind bind
43#define compat_connect connect 33#define compat_connect connect
44#define compat_listen listen 34#define compat_listen listen
45#define compat_close close 35#define compat_close close
46#define compat_select select 36#define compat_select select
47 37
48COMPAT_FD compat_socket(int domain, int type, int protocol); 38#endif /* UNIX_H_ */
49COMPAT_FD compat_accept(COMPAT_FD s, SA *addr, int *len, int deadline);
50int compat_send(COMPAT_FD c, cchar *data, size_t count, size_t *done,
51 int deadline);
52int compat_recv(COMPAT_FD c, uchar *data, size_t count, size_t *done,
53 int deadline);
54int compat_sendto(COMPAT_FD c, cchar *data, size_t count, size_t *done,
55 int deadline, SA *addr, int len);
56int compat_recvfrom(COMPAT_FD c, uchar *data, size_t count, size_t *got,
57 int deadline, SA *addr, int *len);
58void compat_setnonblocking(COMPAT_FD sock);
59void compat_setblocking(COMPAT_FD sock);
60void compat_setreuseaddr(COMPAT_FD sock);
61
62const char *compat_hoststrerror(void);
63const char *compat_socketstrerror(void);
64const char *compat_bindstrerror(void);
65const char *compat_connectstrerror(void);
66
67cchar *compat_trysetoptions(lua_State *L, COMPAT_FD sock);
68
69#endif /* COMPAT_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(...)
13end 13end
14 14
15function warn(...) 15function warn(...)
16 local s = format(unpack(arg)) 16 local s = string.format(unpack(arg))
17 io.write("WARNING: ", s, "\n") 17 io.write("WARNING: ", s, "\n")
18end 18end
19 19