More adjustments/bugfixes.

This commit is contained in:
Diego Nehab 2004-06-21 06:07:58 +00:00
parent f7579db9e8
commit bce1cb30d8
33 changed files with 135 additions and 96 deletions

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: DNS support">
<meta name="keywords" content="Lua, Library, DNS, Network, Support">
<title>LuaSocket: DNS support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>

View File

@ -1,7 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: FTP support">
<meta name="keywords" content="Lua, Library, FTP, Network, Support">
<title>LuaSocket: FTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -14,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: HTTP support">
<meta name="keywords" content="Lua, Library, HTTP, WWW, browser, Network, Support">
<title>LuaSocket: HTTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>

View File

@ -3,6 +3,8 @@
<html>
<head>
<meta name="description" content="The LuaSocket Homepage">
<meta name="keywords" content="Lua, Library, Network, Support, Internet">
<title>LuaSocket: Network support for the Lua language </title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -276,7 +278,7 @@ return convention WILL break old code;
does not call <tt>listen</tt> anymore. It is the new <tt>listen</tt>
method that turns a TCP object into a server object;
<li> <tt>socket.time</tt> became <tt>socket.gettime</tt> for uniformity;
<li> <tt>socket.time</tt> changed to <tt>socket.gettime</tt> for uniformity;
<li> Interface to options has changed.

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: Introduction to the core">
<meta name="keywords" content="Lua, Library, TCP, UDP, Network, Support">
<title>LuaSocket: Introduction to the core</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -209,7 +211,7 @@ print("Please telnet to localhost on port " .. port)
print("After connecting, you have 10s to enter a line to be echoed")
-- loop forever waiting for clients
while 1 do
-- wait for a conection from any client
-- wait for a connection from any client
local client = server:accept()
-- make sure we don't block waiting for this client's line
client:settimeout(10)

View File

@ -3,7 +3,10 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: LTN12 support">
<meta name="keywords" content="Lua, Library, Filters, Source, Sink,
Pump, Support">
<title>LuaSocket: LTN12 module</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +19,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: MIME support">
<meta name="keywords" content="Lua, Library, MIME, Support">
<title>LuaSocket: MIME module</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -92,7 +94,7 @@ The function returns a filter that performs the conversion.
Note: There is no perfect solution to this problem. Different end-of-line
markers are an evil that will probably plague developers forever.
This function, however, will work perfectly for text created with any of
the most common end-of-line markers, i.e. the MacOS (CR), the Unix (LF),
the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF),
or the DOS (CRLF) conventions. Even if the data has mixed end-of-line
markers, the function will still work well, although it doesn't
guarantee that the number of empty lines will be correct.

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language </title>
<meta name="description" content="LuaSocket: Index to reference manual">
<meta name="keywords" content="Lua, Library, Index, Manual, Network, Support">
<title>LuaSocket: Index to reference manual</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: SMTP support">
<meta name="keywords" content="Lua, Library, SMTP, e-mail, MIME, Multipart, Support">
<title>LuaSocket: SMTP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -48,7 +50,7 @@ control (if you bother to read the code).
Another RFC of interest is <a
href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>,
which governs the Internet Message Format.
Multipart messages (those that contain attatchments) are part
Multipart messages (those that contain attachments) are part
of the MIME standard, but described mainly
in <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2046.txt">RFC
2046</a>
@ -98,7 +100,7 @@ in representing them in a Lua table.
</p>
<p>
The following constants can be set to control the default behaviour of
The following constants can be set to control the default behavior of
the SMTP module:
</p>
@ -256,7 +258,7 @@ mesgt = {
to = "Fulano da Silva &lt;fulano@example.com&gt;",
cc = '"Beltrano F. Nunes" &lt;beltrano@example.com&gt;',
subject = "My first message"
}
},
body = "I hope this works. If it does, I can send you another 1000 copies."
}

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: The core namespace">
<meta name="keywords" content="Lua, Library, socket, Network, Support">
<title>LuaSocket: The socket namespace</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -55,6 +57,16 @@ socket.<b>bind(</b>address, port [, backlog]<b>)</b>
</p>
<p class=description>
This function is a shortcut that creates and returns a TCP server object
bound to a local <tt>address</tt> and <tt>port</tt>, ready to
accept client connections. Optionally,
user can also specify the <tt>backlog</tt> argument to the
<a href=tcp.html#listen><tt>listen</tt></a> method (defaults to 32).
</p>
<p class=note>
Note: The server object returned will have the option "<tt>reuseaddr</tt>"
set to <tt><b>true</b></tt>.
</p>
<!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -64,9 +76,9 @@ socket.<b>connect(</b>address, port [, locaddr, locport]<b>)</b>
</p>
<p class=description>
This function is a shortcut that creates and returns a TCP socket object
This function is a shortcut that creates and returns a TCP client object
connected to a remote <tt>host</tt> at a given <tt>port</tt>. Optionally,
the use can also specify the local address and port to bind
the user can also specify the local address and port to bind
(<tt>locaddr</tt> and </tt>locport</tt>).
</p>

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: The TCP/IP support">
<meta name="keywords" content="Lua, Library, socket, TCP, Network, Support">
<title>LuaSocket: TCP/IP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -74,7 +76,7 @@ reported by <b><tt>nil</tt></b> followed by a message describing the error.
</p>
<p class=note>
Note: calling <a href=sockett.html#select><tt>socket.select</tt></a>
Note: calling <a href=socket.html#select><tt>socket.select</tt></a>
with a server object in
the <tt>receive</tt> parameter before a call to <tt>accept</tt> does
<em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a
@ -107,7 +109,7 @@ method returns <b><tt>nil</tt></b> followed by an error message.
</p>
<p class=note>
Note: The function <a href=#socket.bind><tt>socket.bind</tt></a>
Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a>
is available and is a shortcut for the creation server sockets.
</p>
@ -163,15 +165,15 @@ describing the error. In case of success, the method returns 1.
</p>
<p class=note>
Note: The function <a href=#socket.connect><tt>socket.connect</tt></a>
Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a>
is available and is a shortcut for the creation of client sockets.
</p>
<p class=note>
Note: Starting with LuaSocket 2.0,
the <a href=#settimeout><tt>settimeout</tt></a>
function affects the behavior of connect, causing it to return in case of
a timeout error.
method affects the behavior of connect, causing it to return in case of
a timeout.
</p>
<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -197,6 +199,7 @@ Note: It makes no sense to call this method on server objects.
<!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<p class=name id=getsockname>
master:<b>getsockname()</b><br>
client:<b>getsockname()</b><br>
server:<b>getsockname()</b>
</p>

View File

@ -1,10 +1,14 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: The UDP support">
<meta name="keywords" content="Lua, Library, socket, UDP, Network, Support">
<title>LuaSocket: UDP support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
<body>
<!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
@ -14,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -240,7 +244,7 @@ unconnected:<b>setpeername(</b>address, port<b>)</b>
<p class="description">
Changes the peer of a UDP object. This
method turns an unconnected UDP object into a connected UDP
object or vice-versa.
object or vice versa.
</p>
<p class="description">

View File

@ -3,7 +3,9 @@
<html>
<head>
<title>LuaSocket: Network support for the Lua language</title>
<meta name="description" content="LuaSocket: URL manipulation">
<meta name="keywords" content="Lua, Library, URL, link, Network, Support">
<title>LuaSocket: URL support</title>
<link rel="stylesheet" href="reference.css" type="text/css">
</head>
@ -16,7 +18,7 @@
<center>
<table summary="LuaSocket logo">
<tr><td align=center><a href="http://www.lua.org">
<img width=128 border=0 alt="LuaSocket" src="luasocket.png">
<img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png">
</a></td></tr>
<tr><td align=center valign=top>Network support for the Lua language
</td></tr>
@ -135,7 +137,7 @@ Rebuilds an URL from its parts.
<tt>Parsed_url</tt> is a table with same components returned by
<a href="#parse"><tt>parse</tt></a>.
Lower level components, if specified,
take precedence over hight level components of the URL grammar.
take precedence over high level components of the URL grammar.
</p>
<p class=return>
@ -279,8 +281,8 @@ Breaks a <tt>&lt;path&gt;</tt> URL component into all its
<p class=return>
Since some characters are reserved in URLs, they must be escaped
whenever present in a <tt>&lt;path&gt;</tt> component. Therefore, before
returning a list with all the parsed segments, the function unescapes all
of them.
returning a list with all the parsed segments, the function removes
escaping from all of them.
</p>
<!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->

View File

@ -1,5 +1,5 @@
socket = require("socket")
http = require("http")
local socket = require("socket")
local http = require("http")
if not arg or not arg[1] or not arg[2] then
print("luasocket cddb.lua <category> <disc-id> [<server>]")

View File

@ -4,7 +4,7 @@
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
require"socket"
local socket = require"socket"
host = host or "127.0.0.1"
port = port or 13
if arg then

View File

@ -4,7 +4,7 @@
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
socket = require("socket")
local socket = require("socket")
host = host or "127.0.0.1"
port = port or 7
if arg then

View File

@ -4,7 +4,7 @@
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
socket = require("socket")
local socket = require("socket")
host = host or "localhost"
port = port or 8080
if arg then

View File

@ -4,7 +4,7 @@
-- Author: Diego Nehab
-- RCS ID: $Id$
-----------------------------------------------------------------------------
socket = require("socket")
local socket = require("socket")
host = host or "*"
port1 = port1 or 8080
port2 = port2 or 8181

View File

@ -22,8 +22,6 @@ TIMEOUT = 60
PORT = 80
-- user agent field sent in request
USERAGENT = socket.VERSION
-- block size used in transfers
BLOCKSIZE = 2048
-----------------------------------------------------------------------------
-- Low level HTTP API

View File

@ -25,7 +25,10 @@
/*-------------------------------------------------------------------------*\
* 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,7 +19,10 @@
#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

@ -12,9 +12,9 @@ local mime = requirelib("mime", "luaopen_mime", getfenv(1))
local ltn12 = require("ltn12")
-- encode, decode and wrap algorithm tables
encodet = {}
decodet = {}
wrapt = {}
mime.encodet = {}
mime.decodet = {}
mime.wrapt = {}
-- creates a function that chooses a filter by name from a given table
local function choose(table)
@ -29,47 +29,47 @@ local function choose(table)
end
-- define the encoding filters
encodet['base64'] = function()
mime.encodet['base64'] = function()
return ltn12.filter.cycle(b64, "")
end
encodet['quoted-printable'] = function(mode)
mime.encodet['quoted-printable'] = function(mode)
return ltn12.filter.cycle(qp, "",
(mode == "binary") and "=0D=0A" or "\r\n")
end
-- define the decoding filters
decodet['base64'] = function()
mime.decodet['base64'] = function()
return ltn12.filter.cycle(unb64, "")
end
decodet['quoted-printable'] = function()
mime.decodet['quoted-printable'] = function()
return ltn12.filter.cycle(unqp, "")
end
-- define the line-wrap filters
wrapt['text'] = function(length)
mime.wrapt['text'] = function(length)
length = length or 76
return ltn12.filter.cycle(wrp, length, length)
end
wrapt['base64'] = wrapt['text']
wrapt['default'] = wrapt['text']
mime.wrapt['base64'] = wrapt['text']
mime.wrapt['default'] = wrapt['text']
wrapt['quoted-printable'] = function()
mime.wrapt['quoted-printable'] = function()
return ltn12.filter.cycle(qpwrp, 76, 76)
end
-- function that choose the encoding, decoding or wrap algorithm
encode = choose(encodet)
decode = choose(decodet)
wrap = choose(wrapt)
mime.encode = choose(encodet)
mime.decode = choose(decodet)
mime.wrap = choose(wrapt)
-- define the end-of-line normalization filter
function normalize(marker)
function mime.normalize(marker)
return ltn12.filter.cycle(eol, 0, marker)
end
-- high level stuffing filter
function stuff()
function mime.stuff()
return ltn12.filter.cycle(dot, 2)
end

View File

@ -8,7 +8,6 @@
-- Load LuaSocket from dynamic library
-----------------------------------------------------------------------------
local socket = requirelib("luasocket", "luaopen_socket", getfenv(1))
_LOADED["socket"] = socket
-----------------------------------------------------------------------------
-- Auxiliar functions
@ -31,7 +30,7 @@ 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 1
backlog = backlog or 32
res, err = sock:listen(backlog)
if not res then return nil, err end
return sock

View File

@ -130,7 +130,7 @@ static int meth_setoption(lua_State *L)
static int meth_getfd(lua_State *L)
{
p_tcp tcp = (p_tcp) aux_checkgroup(L, "tcp{any}", 1);
lua_pushnumber(L, tcp->sock);
lua_pushnumber(L, (int) tcp->sock);
return 1;
}
@ -164,6 +164,7 @@ static int meth_accept(lua_State *L)
p_tcp clnt = lua_newuserdata(L, sizeof(t_tcp));
aux_setclass(L, "tcp{client}", -1);
/* initialize structure fields */
sock_setnonblocking(&sock);
clnt->sock = sock;
io_init(&clnt->io, (p_send)sock_send, (p_recv)sock_recv, &clnt->sock);
tm_init(&clnt->tm, -1, -1);
@ -310,10 +311,11 @@ static int global_create(lua_State *L)
if (!err) {
/* allocate tcp object */
p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp));
tcp->sock = sock;
/* set its type as master object */
aux_setclass(L, "tcp{master}", -1);
/* initialize remaining structure fields */
sock_setnonblocking(&sock);
tcp->sock = sock;
io_init(&tcp->io, (p_send) sock_send, (p_recv) sock_recv, &tcp->sock);
tm_init(&tcp->tm, -1, -1);
buf_init(&tcp->buf, &tcp->io, &tcp->tm);

View File

@ -208,7 +208,7 @@ static int meth_receivefrom(lua_State *L)
static int meth_getfd(lua_State *L)
{
p_udp udp = (p_udp) aux_checkgroup(L, "udp{any}", 1);
lua_pushnumber(L, udp->sock);
lua_pushnumber(L, (int) udp->sock);
return 1;
}
@ -328,10 +328,10 @@ static int global_create(lua_State *L)
if (!err) {
/* allocate tcp object */
p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp));
udp->sock = sock;
/* set its type as master object */
aux_setclass(L, "udp{unconnected}", -1);
/* initialize remaining structure fields */
sock_setnonblocking(&sock);
udp->sock = sock;
tm_init(&udp->tm, -1, -1);
return 1;
} else {

View File

@ -81,7 +81,6 @@ const char *sock_create(p_sock ps, int domain, int type, int protocol)
t_sock sock = socket(domain, type, protocol);
if (sock == SOCK_INVALID) return sock_createstrerror(errno);
*ps = sock;
sock_setnonblocking(ps);
return NULL;
}
@ -178,10 +177,7 @@ const char *sock_accept(p_sock ps, p_sock pa, SA *addr,
do *pa = accept(sock, addr, addr_len);
while (*pa < 0 && errno == EINTR);
/* if result is valid, we are done */
if (*pa != SOCK_INVALID) {
sock_setnonblocking(pa);
return NULL;
}
if (*pa != SOCK_INVALID) return NULL;
/* find out if we failed for a fatal reason */
if (errno != EWOULDBLOCK && errno != ECONNABORTED)
return sock_acceptstrerror(errno);

View File

@ -88,7 +88,6 @@ const char *sock_create(p_sock ps, int domain, int type, int protocol)
if (sock == SOCK_INVALID)
return sock_createstrerror(WSAGetLastError());
*ps = sock;
sock_setnonblocking(ps);
return NULL;
}
@ -177,10 +176,7 @@ const char *sock_accept(p_sock ps, p_sock pa, SA *addr,
/* try to get client socket */
*pa = accept(sock, addr, addr_len);
/* if return is valid, we are done */
if (*pa != SOCK_INVALID) {
sock_setnonblocking(pa);
return NULL;
}
if (*pa != SOCK_INVALID) return NULL;
/* optimization */
if (timeout == 0) return io_strerror(IO_TIMEOUT);
/* otherwise find out why we failed */

View File

@ -4,11 +4,11 @@
-- to "/luasocket-test-cgi" and "/luasocket-test-cgi/"
-- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth
socket = require("socket")
http = require("http")
mime = require("mime")
url = require("url")
ltn12 = require("ltn12")
local socket = require("socket")
local http = require("http")
local mime = require("mime")
local url = require("url")
local ltn12 = require("ltn12")
dofile("testsupport.lua")

View File

@ -8,7 +8,7 @@ local qptest = "qptest.bin"
local eqptest = "qptest.bin2"
local dqptest = "qptest.bin3"
local b64test = "luasocket.dll"
local b64test = "luasocket.dylib"
local eb64test = "b64test.bin"
local db64test = "b64test.bin2"

View File

@ -1,4 +1,4 @@
mime = require("mime")
local mime = require("mime")
function test_dot(original, right)
local result, n = mime.dot(2, original)

View File

@ -1,4 +1,4 @@
socket = require"socket"
local socket = require"socket"
host = host or "localhost"
port = port or "8080"
@ -418,7 +418,7 @@ function connect_errors()
assert(not c and e == "connection refused", e)
print("ok")
io.stderr:write("host not found: ")
local c, e = socket.connect("not.exist.com", 1);
local c, e = socket.connect("host.is.invalid", 1);
assert(not c and e == "host not found", e)
print("ok")
end

View File

@ -1,4 +1,4 @@
socket = require"socket"
local socket = require"socket"
host = host or "localhost"
port = port or "8080"

View File

@ -1,4 +1,4 @@
socket = require("socket")
local socket = require("socket")
socket.url = require("url")
dofile("testsupport.lua")