Changed prefix of function names to match module names.

Removed some warnings and useless code.
This commit is contained in:
Diego Nehab 2005-11-20 07:20:26 +00:00
parent 087b4f865d
commit f20f4889bf
11 changed files with 110 additions and 89 deletions

20
config
View File

@ -37,20 +37,20 @@ INSTALL_EXEC=cp
# Compiler and linker settings # Compiler and linker settings
# for Mac OS X # for Mac OS X
# #
CC=gcc #CC=gcc
DEF=-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN #DEF=-DLUASOCKET_DEBUG -DUNIX_HAS_SUN_LEN
CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common #CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fno-common
LDFLAGS=-bundle -undefined dynamic_lookup #LDFLAGS=-bundle -undefined dynamic_lookup
LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc #LD=export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
#------ #------
# Compiler and linker settings # Compiler and linker settings
# for Linux # for Linux
#CC=gcc CC=gcc
#DEF=-DLUASOCKET_DEBUG DEF=-DLUASOCKET_DEBUG
#CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fpic CFLAGS= $(LUAINC) -I$(COMPAT) $(DEF) -pedantic -Wall -O2 -fpic
#LDFLAGS=-O -shared LDFLAGS=-O -shared
#LD=gcc LD=gcc
#------ #------
# End of makefile configuration # End of makefile configuration

View File

@ -72,7 +72,7 @@
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MIME_EXPORTS; MIME_API=__declspec(dllexport)"
RuntimeLibrary="2" RuntimeLibrary="2"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="4"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0"/> DebugInformationFormat="0"/>
<Tool <Tool

View File

@ -156,6 +156,12 @@
</File> </File>
<File <File
RelativePath="src\wsocket.c"> RelativePath="src\wsocket.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
GeneratePreprocessedFile="0"/>
</FileConfiguration>
</File> </File>
</Filter> </Filter>
<Filter <Filter

View File

@ -152,8 +152,8 @@ static int mime_global_wrp(lua_State *L)
static void b64setup(UC *b64unbase) static void b64setup(UC *b64unbase)
{ {
int i; int i;
for (i = 0; i < 255; i++) b64unbase[i] = 255; for (i = 0; i <= 255; i++) b64unbase[i] = (UC) 255;
for (i = 0; i < 64; i++) b64unbase[b64base[i]] = i; for (i = 0; i < 64; i++) b64unbase[b64base[i]] = (UC) i;
b64unbase['='] = 0; b64unbase['='] = 0;
} }
@ -191,7 +191,7 @@ static size_t b64pad(const UC *input, size_t size,
luaL_Buffer *buffer) luaL_Buffer *buffer)
{ {
unsigned long value = 0; unsigned long value = 0;
UC code[4] = "===="; UC code[4] = {'=', '=', '=', '='};
switch (size) { switch (size) {
case 1: case 1:
value = input[0] << 4; value = input[0] << 4;
@ -480,38 +480,31 @@ static int mime_global_qp(lua_State *L)
* Accumulate characters until we are sure about how to deal with them. * Accumulate characters until we are sure about how to deal with them.
* Once we are sure, output the to the buffer, in the correct form. * Once we are sure, output the to the buffer, in the correct form.
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
static size_t qpdecode(UC c, UC *input, size_t size, static size_t qpdecode(UC c, UC *input, size_t size, luaL_Buffer *buffer) {
luaL_Buffer *buffer) int d;
{
input[size++] = c; input[size++] = c;
/* deal with all characters we can deal */ /* deal with all characters we can deal */
while (size > 0) { switch (input[0]) {
int c, d; /* if we have an escape character */
switch (input[0]) { case '=':
/* if we have an escape character */ if (size < 3) return size;
case '=': /* eliminate soft line break */
if (size < 3) return size; if (input[1] == '\r' && input[2] == '\n') return 0;
/* eliminate soft line break */ /* decode quoted representation */
if (input[1] == '\r' && input[2] == '\n') return 0; c = qpunbase[input[1]]; d = qpunbase[input[2]];
/* decode quoted representation */ /* if it is an invalid, do not decode */
c = qpunbase[input[1]]; d = qpunbase[input[2]]; if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3);
/* if it is an invalid, do not decode */ else luaL_putchar(buffer, (c << 4) + d);
if (c > 15 || d > 15) luaL_addlstring(buffer, (char *)input, 3); return 0;
else luaL_putchar(buffer, (c << 4) + d); case '\r':
return 0; if (size < 2) return size;
case '\r': if (input[1] == '\n') luaL_addlstring(buffer, (char *)input, 2);
if (size < 2) return size; return 0;
if (input[1] == '\n') luaL_addlstring(buffer, (char *)input, 2); default:
return 0; if (input[0] == '\t' || (input[0] > 31 && input[0] < 127))
default: luaL_putchar(buffer, input[0]);
if (input[0] == '\t' || (input[0] > 31 && input[0] < 127)) return 0;
luaL_putchar(buffer, input[0]);
return 0;
}
input[0] = input[1]; input[1] = input[2];
size--;
} }
return 0;
} }
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\

View File

@ -80,12 +80,12 @@ int opt_linger(lua_State *L, p_socket ps)
lua_gettable(L, 3); lua_gettable(L, 3);
if (!lua_isboolean(L, -1)) if (!lua_isboolean(L, -1))
luaL_argerror(L, 3, "boolean 'on' field expected"); luaL_argerror(L, 3, "boolean 'on' field expected");
li.l_onoff = lua_toboolean(L, -1); li.l_onoff = (u_short) lua_toboolean(L, -1);
lua_pushstring(L, "timeout"); lua_pushstring(L, "timeout");
lua_gettable(L, 3); lua_gettable(L, 3);
if (!lua_isnumber(L, -1)) if (!lua_isnumber(L, -1))
luaL_argerror(L, 3, "number 'timeout' field expected"); luaL_argerror(L, 3, "number 'timeout' field expected");
li.l_linger = (int) lua_tonumber(L, -1); li.l_linger = (u_short) lua_tonumber(L, -1);
return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li)); return opt_set(L, ps, SOL_SOCKET, SO_LINGER, (char *) &li, sizeof(li));
} }

View File

@ -16,11 +16,12 @@
/*=========================================================================*\ /*=========================================================================*\
* Internal function prototypes. * Internal function prototypes.
\*=========================================================================*/ \*=========================================================================*/
static int getfd(lua_State *L); static t_socket getfd(lua_State *L);
static int dirty(lua_State *L); static int dirty(lua_State *L);
static int collect_fd(lua_State *L, int tab, int max_fd, int itab, fd_set *set); static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
int itab, fd_set *set);
static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set); static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set);
static void return_fd(lua_State *L, fd_set *set, int max_fd, static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
int itab, int tab, int start); int itab, int tab, int start);
static void make_assoc(lua_State *L, int tab); static void make_assoc(lua_State *L, int tab);
static int global_select(lua_State *L); static int global_select(lua_State *L);
@ -49,7 +50,8 @@ int select_open(lua_State *L) {
* Waits for a set of sockets until a condition is met or timeout. * Waits for a set of sockets until a condition is met or timeout.
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
static int global_select(lua_State *L) { static int global_select(lua_State *L) {
int rtab, wtab, itab, max_fd, ret, ndirty; int rtab, wtab, itab, ret, ndirty;
t_socket max_fd;
fd_set rset, wset; fd_set rset, wset;
t_timeout tm; t_timeout tm;
double t = luaL_optnumber(L, 3, -1); double t = luaL_optnumber(L, 3, -1);
@ -58,7 +60,7 @@ static int global_select(lua_State *L) {
lua_newtable(L); itab = lua_gettop(L); lua_newtable(L); itab = lua_gettop(L);
lua_newtable(L); rtab = lua_gettop(L); lua_newtable(L); rtab = lua_gettop(L);
lua_newtable(L); wtab = lua_gettop(L); lua_newtable(L); wtab = lua_gettop(L);
max_fd = collect_fd(L, 1, -1, itab, &rset); max_fd = collect_fd(L, 1, SOCKET_INVALID, itab, &rset);
ndirty = check_dirty(L, 1, rtab, &rset); ndirty = check_dirty(L, 1, rtab, &rset);
t = ndirty > 0? 0.0: t; t = ndirty > 0? 0.0: t;
timeout_init(&tm, t, -1); timeout_init(&tm, t, -1);
@ -83,15 +85,15 @@ static int global_select(lua_State *L) {
/*=========================================================================*\ /*=========================================================================*\
* Internal functions * Internal functions
\*=========================================================================*/ \*=========================================================================*/
static int getfd(lua_State *L) { static t_socket getfd(lua_State *L) {
int fd = -1; t_socket fd = SOCKET_INVALID;
lua_pushstring(L, "getfd"); lua_pushstring(L, "getfd");
lua_gettable(L, -2); lua_gettable(L, -2);
if (!lua_isnil(L, -1)) { if (!lua_isnil(L, -1)) {
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_call(L, 1, 1); lua_call(L, 1, 1);
if (lua_isnumber(L, -1)) if (lua_isnumber(L, -1))
fd = (int) lua_tonumber(L, -1); fd = (t_socket) lua_tonumber(L, -1);
} }
lua_pop(L, 1); lua_pop(L, 1);
return fd; return fd;
@ -110,13 +112,13 @@ static int dirty(lua_State *L) {
return is; return is;
} }
static int collect_fd(lua_State *L, int tab, int max_fd, static t_socket collect_fd(lua_State *L, int tab, t_socket max_fd,
int itab, fd_set *set) { int itab, fd_set *set) {
int i = 1; int i = 1;
if (lua_isnil(L, tab)) if (lua_isnil(L, tab))
return max_fd; return max_fd;
while (1) { while (1) {
int fd; t_socket fd;
lua_pushnumber(L, i); lua_pushnumber(L, i);
lua_gettable(L, tab); lua_gettable(L, tab);
if (lua_isnil(L, -1)) { if (lua_isnil(L, -1)) {
@ -124,9 +126,10 @@ static int collect_fd(lua_State *L, int tab, int max_fd,
break; break;
} }
fd = getfd(L); fd = getfd(L);
if (fd >= 0) { if (fd != SOCKET_INVALID) {
FD_SET(fd, set); FD_SET(fd, set);
if (max_fd < fd) max_fd = fd; if (max_fd == SOCKET_INVALID || max_fd < fd)
max_fd = fd;
lua_pushnumber(L, fd); lua_pushnumber(L, fd);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_settable(L, itab); lua_settable(L, itab);
@ -141,8 +144,8 @@ static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
int ndirty = 0, i = 1; int ndirty = 0, i = 1;
if (lua_isnil(L, tab)) if (lua_isnil(L, tab))
return 0; return 0;
while (1) { while (1) {
int fd; t_socket fd;
lua_pushnumber(L, i); lua_pushnumber(L, i);
lua_gettable(L, tab); lua_gettable(L, tab);
if (lua_isnil(L, -1)) { if (lua_isnil(L, -1)) {
@ -150,7 +153,7 @@ static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
break; break;
} }
fd = getfd(L); fd = getfd(L);
if (fd >= 0 && dirty(L)) { if (fd != SOCKET_INVALID && dirty(L)) {
lua_pushnumber(L, ++ndirty); lua_pushnumber(L, ++ndirty);
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_settable(L, dtab); lua_settable(L, dtab);
@ -162,9 +165,9 @@ static int check_dirty(lua_State *L, int tab, int dtab, fd_set *set) {
return ndirty; return ndirty;
} }
static void return_fd(lua_State *L, fd_set *set, int max_fd, static void return_fd(lua_State *L, fd_set *set, t_socket max_fd,
int itab, int tab, int start) { int itab, int tab, int start) {
int fd; t_socket fd;
for (fd = 0; fd < max_fd; fd++) { for (fd = 0; fd < max_fd; fd++) {
if (FD_ISSET(fd, set)) { if (FD_ISSET(fd, set)) {
lua_pushnumber(L, ++start); lua_pushnumber(L, ++start);

View File

@ -50,7 +50,8 @@ void socket_setnonblocking(p_socket ps);
void socket_setblocking(p_socket ps); void socket_setblocking(p_socket ps);
int socket_waitfd(p_socket ps, int sw, p_timeout tm); int socket_waitfd(p_socket ps, int sw, p_timeout tm);
int socket_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm); int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
p_timeout tm);
int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm); int socket_connect(p_socket ps, SA *addr, socklen_t addr_len, p_timeout tm);
int socket_create(p_socket ps, int domain, int type, int protocol); int socket_create(p_socket ps, int domain, int type, int protocol);

View File

@ -130,29 +130,41 @@ function parse(url, default)
-- remove whitespace -- remove whitespace
-- url = string.gsub(url, "%s", "") -- url = string.gsub(url, "%s", "")
-- get fragment -- get fragment
url = string.gsub(url, "#(.*)$", function(f) parsed.fragment = f end) url = string.gsub(url, "#(.*)$", function(f)
parsed.fragment = f
return ""
end)
-- get scheme -- get scheme
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:", url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
function(s) parsed.scheme = s end) function(s) parsed.scheme = s; return "" end)
-- get authority -- get authority
url = string.gsub(url, "^//([^/]*)", function(n) parsed.authority = n end) url = string.gsub(url, "^//([^/]*)", function(n)
parsed.authority = n
return ""
end)
-- get query stringing -- get query stringing
url = string.gsub(url, "%?(.*)", function(q) parsed.query = q end) url = string.gsub(url, "%?(.*)", function(q)
parsed.query = q
return ""
end)
-- get params -- get params
url = string.gsub(url, "%;(.*)", function(p) parsed.params = p end) url = string.gsub(url, "%;(.*)", function(p)
parsed.params = p
return ""
end)
-- path is whatever was left -- path is whatever was left
if url ~= "" then parsed.path = url end if url ~= "" then parsed.path = url end
local authority = parsed.authority local authority = parsed.authority
if not authority then return parsed end if not authority then return parsed end
authority = string.gsub(authority,"^([^@]*)@", authority = string.gsub(authority,"^([^@]*)@",
function(u) parsed.userinfo = u end) function(u) parsed.userinfo = u; return "" end)
authority = string.gsub(authority, ":([^:]*)$", authority = string.gsub(authority, ":([^:]*)$",
function(p) parsed.port = p end) function(p) parsed.port = p; return "" end)
if authority ~= "" then parsed.host = authority end if authority ~= "" then parsed.host = authority end
local userinfo = parsed.userinfo local userinfo = parsed.userinfo
if not userinfo then return parsed end if not userinfo then return parsed end
userinfo = string.gsub(userinfo, ":([^:]*)$", userinfo = string.gsub(userinfo, ":([^:]*)$",
function(p) parsed.password = p end) function(p) parsed.password = p; return "" end)
parsed.user = userinfo parsed.user = userinfo
return parsed return parsed
end end
@ -283,4 +295,3 @@ function build_path(parsed, unsafe)
if parsed.is_absolute then path = "/" .. path end if parsed.is_absolute then path = "/" .. path end
return path return path
end end

View File

@ -102,7 +102,8 @@ void socket_destroy(p_socket ps) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Select with timeout control * Select with timeout control
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_timeout tm) { int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
p_timeout tm) {
int ret; int ret;
do { do {
struct timeval tv; struct timeval tv;

View File

@ -46,16 +46,20 @@ int socket_close(void) {
#define WAITFD_E 4 #define WAITFD_E 4
#define WAITFD_C (WAITFD_E|WAITFD_W) #define WAITFD_C (WAITFD_E|WAITFD_W)
int socket_waitfd(p_socket ps, int sw, p_tm tm) { int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
int ret; int ret;
fd_set rfds, wfds, efds, *rp = NULL, *wp = NULL, *ep = NULL; fd_set rfds, wfds, efds, *rp = NULL, *wp = NULL, *ep = NULL;
struct timeval tv, *tp = NULL; struct timeval tv, *tp = NULL;
double t; double t;
if (tm_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */ if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
if (sw & WAITFD_R) { FD_ZERO(&rfds); FD_SET(*ps, &rfds); rp = &rfds; } if (sw & WAITFD_R) {
FD_ZERO(&rfds);
FD_SET(*ps, &rfds);
rp = &rfds;
}
if (sw & WAITFD_W) { FD_ZERO(&wfds); FD_SET(*ps, &wfds); wp = &wfds; } if (sw & WAITFD_W) { FD_ZERO(&wfds); FD_SET(*ps, &wfds); wp = &wfds; }
if (sw & WAITFD_C) { FD_ZERO(&efds); FD_SET(*ps, &efds); ep = &efds; } if (sw & WAITFD_C) { FD_ZERO(&efds); FD_SET(*ps, &efds); ep = &efds; }
if ((t = tm_get(tm)) >= 0.0) { if ((t = timeout_get(tm)) >= 0.0) {
tv.tv_sec = (int) t; tv.tv_sec = (int) t;
tv.tv_usec = (int) ((t-tv.tv_sec)*1.0e6); tv.tv_usec = (int) ((t-tv.tv_sec)*1.0e6);
tp = &tv; tp = &tv;
@ -70,9 +74,10 @@ int socket_waitfd(p_socket ps, int sw, p_tm tm) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Select with int timeout in ms * Select with int timeout in ms
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, p_tm tm) { int socket_select(t_socket n, fd_set *rfds, fd_set *wfds, fd_set *efds,
p_timeout tm) {
struct timeval tv; struct timeval tv;
double t = tm_get(tm); double t = timeout_get(tm);
tv.tv_sec = (int) t; tv.tv_sec = (int) t;
tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6); tv.tv_usec = (int) ((t - tv.tv_sec) * 1.0e6);
if (n <= 0) { if (n <= 0) {
@ -113,7 +118,7 @@ int socket_create(p_socket ps, int domain, int type, int protocol) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Connects or returns error message * Connects or returns error message
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_connect(p_socket ps, SA *addr, socklen_t len, p_tm tm) { int socket_connect(p_socket ps, SA *addr, socklen_t len, p_timeout tm) {
int err; int err;
/* don't call on closed socket */ /* don't call on closed socket */
if (*ps == SOCKET_INVALID) return IO_CLOSED; if (*ps == SOCKET_INVALID) return IO_CLOSED;
@ -123,7 +128,7 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_tm tm) {
err = WSAGetLastError(); err = WSAGetLastError();
if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err; if (err != WSAEWOULDBLOCK && err != WSAEINPROGRESS) return err;
/* zero timeout case optimization */ /* zero timeout case optimization */
if (tm_iszero(tm)) return IO_TIMEOUT; if (timeout_iszero(tm)) return IO_TIMEOUT;
/* we wait until something happens */ /* we wait until something happens */
err = socket_waitfd(ps, WAITFD_C, tm); err = socket_waitfd(ps, WAITFD_C, tm);
if (err == IO_CLOSED) { if (err == IO_CLOSED) {
@ -131,7 +136,7 @@ int socket_connect(p_socket ps, SA *addr, socklen_t len, p_tm tm) {
/* give windows time to set the error (yes, disgusting) */ /* give windows time to set the error (yes, disgusting) */
Sleep(10); Sleep(10);
/* find out why we failed */ /* find out why we failed */
getsockopt(*ps, SOL_SOCKETET, SO_ERROR, (char *)&err, &len); getsockopt(*ps, SOL_SOCKET, SO_ERROR, (char *)&err, &len);
/* we KNOW there was an error. if 'why' is 0, we will return /* we KNOW there was an error. if 'why' is 0, we will return
* "unknown error", but it's not really our fault */ * "unknown error", but it's not really our fault */
return err > 0? err: IO_UNKNOWN; return err > 0? err: IO_UNKNOWN;
@ -164,7 +169,8 @@ int socket_listen(p_socket ps, int backlog) {
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Accept with timeout * Accept with timeout
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_tm tm) { int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len,
p_timeout tm) {
SA daddr; SA daddr;
socklen_t dlen = sizeof(daddr); socklen_t dlen = sizeof(daddr);
if (*ps == SOCKET_INVALID) return IO_CLOSED; if (*ps == SOCKET_INVALID) return IO_CLOSED;
@ -192,7 +198,7 @@ int socket_accept(p_socket ps, p_socket pa, SA *addr, socklen_t *len, p_tm tm) {
* Therefore, whoever calls this function should not pass a huge buffer. * Therefore, whoever calls this function should not pass a huge buffer.
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_send(p_socket ps, const char *data, size_t count, int socket_send(p_socket ps, const char *data, size_t count,
size_t *sent, p_tm tm) size_t *sent, p_timeout tm)
{ {
int err; int err;
/* avoid making system calls on closed sockets */ /* avoid making system calls on closed sockets */
@ -222,7 +228,7 @@ int socket_send(p_socket ps, const char *data, size_t count,
* Sendto with timeout * Sendto with timeout
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent, int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
SA *addr, socklen_t len, p_tm tm) SA *addr, socklen_t len, p_timeout tm)
{ {
int err; int err;
if (*ps == SOCKET_INVALID) return IO_CLOSED; if (*ps == SOCKET_INVALID) return IO_CLOSED;
@ -243,7 +249,7 @@ int socket_sendto(p_socket ps, const char *data, size_t count, size_t *sent,
/*-------------------------------------------------------------------------*\ /*-------------------------------------------------------------------------*\
* Receive with timeout * Receive with timeout
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_tm tm) { int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm) {
int err; int err;
if (*ps == SOCKET_INVALID) return IO_CLOSED; if (*ps == SOCKET_INVALID) return IO_CLOSED;
*got = 0; *got = 0;
@ -265,7 +271,7 @@ int socket_recv(p_socket ps, char *data, size_t count, size_t *got, p_tm tm) {
* Recvfrom with timeout * Recvfrom with timeout
\*-------------------------------------------------------------------------*/ \*-------------------------------------------------------------------------*/
int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got, int socket_recvfrom(p_socket ps, char *data, size_t count, size_t *got,
SA *addr, socklen_t *len, p_tm tm) { SA *addr, socklen_t *len, p_timeout tm) {
int err; int err;
if (*ps == SOCKET_INVALID) return IO_CLOSED; if (*ps == SOCKET_INVALID) return IO_CLOSED;
*got = 0; *got = 0;

View File

@ -22,8 +22,8 @@ http.TIMEOUT = 10
local t = socket.gettime() local t = socket.gettime()
host = host or "localhost" -- "diego.student.princeton.edu" host = host or "dell-diego" -- "diego.student.princeton.edu"
proxy = proxy or "http://localhost:3128" proxy = proxy or "http://dell-diego:3128"
prefix = prefix or "/luasocket-test" prefix = prefix or "/luasocket-test"
cgiprefix = cgiprefix or "/luasocket-test-cgi" cgiprefix = cgiprefix or "/luasocket-test-cgi"
index_file = "index.html" index_file = "index.html"