diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
commit | bce1cb30d856d167e167c4c2997f9bebe03a612c (patch) | |
tree | 8e684b912cdc9d27c5aebf593107487c94866438 | |
parent | f7579db9e830ef41f422a280d26c9077f48728e5 (diff) | |
download | luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.gz luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.bz2 luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.zip |
More adjustments/bugfixes.
-rw-r--r-- | doc/dns.html | 6 | ||||
-rw-r--r-- | doc/ftp.html | 10 | ||||
-rw-r--r-- | doc/http.html | 6 | ||||
-rw-r--r-- | doc/index.html | 6 | ||||
-rw-r--r-- | doc/introduction.html | 8 | ||||
-rw-r--r-- | doc/ltn12.html | 7 | ||||
-rw-r--r-- | doc/mime.html | 8 | ||||
-rw-r--r-- | doc/reference.html | 6 | ||||
-rw-r--r-- | doc/smtp.html | 12 | ||||
-rw-r--r-- | doc/socket.html | 20 | ||||
-rw-r--r-- | doc/tcp.html | 17 | ||||
-rw-r--r-- | doc/udp.html | 12 | ||||
-rw-r--r-- | doc/url.html | 12 | ||||
-rw-r--r-- | samples/cddb.lua | 4 | ||||
-rw-r--r-- | samples/daytimeclnt.lua | 2 | ||||
-rw-r--r-- | samples/echosrvr.lua | 2 | ||||
-rw-r--r-- | samples/talker.lua | 2 | ||||
-rw-r--r-- | samples/tinyirc.lua | 2 | ||||
-rw-r--r-- | src/http.lua | 2 | ||||
-rw-r--r-- | src/luasocket.h | 3 | ||||
-rw-r--r-- | src/mime.h | 3 | ||||
-rw-r--r-- | src/mime.lua | 32 | ||||
-rw-r--r-- | src/socket.lua | 3 | ||||
-rw-r--r-- | src/tcp.c | 6 | ||||
-rw-r--r-- | src/udp.c | 6 | ||||
-rw-r--r-- | src/usocket.c | 6 | ||||
-rw-r--r-- | src/wsocket.c | 6 | ||||
-rw-r--r-- | test/httptest.lua | 10 | ||||
-rw-r--r-- | test/mimetest.lua | 2 | ||||
-rw-r--r-- | test/stufftest.lua | 2 | ||||
-rw-r--r-- | test/testclnt.lua | 4 | ||||
-rw-r--r-- | test/testsrvr.lua | 2 | ||||
-rw-r--r-- | test/urltest.lua | 2 |
33 files changed, 135 insertions, 96 deletions
diff --git a/doc/dns.html b/doc/dns.html index 47134d8..09a9bdb 100644 --- a/doc/dns.html +++ b/doc/dns.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: DNS support"> |
7 | <meta name="keywords" content="Lua, Library, DNS, Network, Support"> | ||
8 | <title>LuaSocket: DNS support</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
diff --git a/doc/ftp.html b/doc/ftp.html index fe514e9..158b402 100644 --- a/doc/ftp.html +++ b/doc/ftp.html | |||
@@ -1,7 +1,11 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 | "http://www.w3.org/TR/html4/strict.dtd"> | ||
3 | <html> | ||
2 | 4 | ||
3 | <head> | 5 | <head> |
4 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: FTP support"> |
7 | <meta name="keywords" content="Lua, Library, FTP, Network, Support"> | ||
8 | <title>LuaSocket: FTP support</title> | ||
5 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
6 | </head> | 10 | </head> |
7 | 11 | ||
@@ -14,7 +18,7 @@ | |||
14 | <center> | 18 | <center> |
15 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
16 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
17 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
18 | </a></td></tr> | 22 | </a></td></tr> |
19 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
20 | </td></tr> | 24 | </td></tr> |
diff --git a/doc/http.html b/doc/http.html index 4780436..13acd1c 100644 --- a/doc/http.html +++ b/doc/http.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: HTTP support"> |
7 | <meta name="keywords" content="Lua, Library, HTTP, WWW, browser, Network, Support"> | ||
8 | <title>LuaSocket: HTTP support</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
diff --git a/doc/index.html b/doc/index.html index 0e9eb1d..abba703 100644 --- a/doc/index.html +++ b/doc/index.html | |||
@@ -3,6 +3,8 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <meta name="description" content="The LuaSocket Homepage"> | ||
7 | <meta name="keywords" content="Lua, Library, Network, Support, Internet"> | ||
6 | <title>LuaSocket: Network support for the Lua language </title> | 8 | <title>LuaSocket: Network support for the Lua language </title> |
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -276,7 +278,7 @@ return convention WILL break old code; | |||
276 | does not call <tt>listen</tt> anymore. It is the new <tt>listen</tt> | 278 | does not call <tt>listen</tt> anymore. It is the new <tt>listen</tt> |
277 | method that turns a TCP object into a server object; | 279 | method that turns a TCP object into a server object; |
278 | 280 | ||
279 | <li> <tt>socket.time</tt> became <tt>socket.gettime</tt> for uniformity; | 281 | <li> <tt>socket.time</tt> changed to <tt>socket.gettime</tt> for uniformity; |
280 | 282 | ||
281 | <li> Interface to options has changed. | 283 | <li> Interface to options has changed. |
282 | 284 | ||
diff --git a/doc/introduction.html b/doc/introduction.html index 2c738d6..6468148 100644 --- a/doc/introduction.html +++ b/doc/introduction.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: Introduction to the core"> |
7 | <meta name="keywords" content="Lua, Library, TCP, UDP, Network, Support"> | ||
8 | <title>LuaSocket: Introduction to the core</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -209,7 +211,7 @@ print("Please telnet to localhost on port " .. port) | |||
209 | print("After connecting, you have 10s to enter a line to be echoed") | 211 | print("After connecting, you have 10s to enter a line to be echoed") |
210 | -- loop forever waiting for clients | 212 | -- loop forever waiting for clients |
211 | while 1 do | 213 | while 1 do |
212 | -- wait for a conection from any client | 214 | -- wait for a connection from any client |
213 | local client = server:accept() | 215 | local client = server:accept() |
214 | -- make sure we don't block waiting for this client's line | 216 | -- make sure we don't block waiting for this client's line |
215 | client:settimeout(10) | 217 | client:settimeout(10) |
diff --git a/doc/ltn12.html b/doc/ltn12.html index bfb9b51..40dcf96 100644 --- a/doc/ltn12.html +++ b/doc/ltn12.html | |||
@@ -3,7 +3,10 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: LTN12 support"> |
7 | <meta name="keywords" content="Lua, Library, Filters, Source, Sink, | ||
8 | Pump, Support"> | ||
9 | <title>LuaSocket: LTN12 module</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 10 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 11 | </head> |
9 | 12 | ||
@@ -16,7 +19,7 @@ | |||
16 | <center> | 19 | <center> |
17 | <table summary="LuaSocket logo"> | 20 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 21 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 22 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 23 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 24 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 25 | </td></tr> |
diff --git a/doc/mime.html b/doc/mime.html index 0f4ffa8..6758a4b 100644 --- a/doc/mime.html +++ b/doc/mime.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: MIME support"> |
7 | <meta name="keywords" content="Lua, Library, MIME, Support"> | ||
8 | <title>LuaSocket: MIME module</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -92,7 +94,7 @@ The function returns a filter that performs the conversion. | |||
92 | Note: There is no perfect solution to this problem. Different end-of-line | 94 | Note: There is no perfect solution to this problem. Different end-of-line |
93 | markers are an evil that will probably plague developers forever. | 95 | markers are an evil that will probably plague developers forever. |
94 | This function, however, will work perfectly for text created with any of | 96 | This function, however, will work perfectly for text created with any of |
95 | the most common end-of-line markers, i.e. the MacOS (CR), the Unix (LF), | 97 | the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), |
96 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line | 98 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line |
97 | markers, the function will still work well, although it doesn't | 99 | markers, the function will still work well, although it doesn't |
98 | guarantee that the number of empty lines will be correct. | 100 | guarantee that the number of empty lines will be correct. |
diff --git a/doc/reference.html b/doc/reference.html index 5c07c4d..8d129e3 100644 --- a/doc/reference.html +++ b/doc/reference.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language </title> | 6 | <meta name="description" content="LuaSocket: Index to reference manual"> |
7 | <meta name="keywords" content="Lua, Library, Index, Manual, Network, Support"> | ||
8 | <title>LuaSocket: Index to reference manual</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
diff --git a/doc/smtp.html b/doc/smtp.html index 224dde3..b975045 100644 --- a/doc/smtp.html +++ b/doc/smtp.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: SMTP support"> |
7 | <meta name="keywords" content="Lua, Library, SMTP, e-mail, MIME, Multipart, Support"> | ||
8 | <title>LuaSocket: SMTP support</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -48,7 +50,7 @@ control (if you bother to read the code). | |||
48 | Another RFC of interest is <a | 50 | Another RFC of interest is <a |
49 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, | 51 | href="http://www.cs.princeton.edu/~diego/rfc/rfc2822.txt">RFC 2822</a>, |
50 | which governs the Internet Message Format. | 52 | which governs the Internet Message Format. |
51 | Multipart messages (those that contain attatchments) are part | 53 | Multipart messages (those that contain attachments) are part |
52 | of the MIME standard, but described mainly | 54 | of the MIME standard, but described mainly |
53 | in <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2046.txt">RFC | 55 | in <a href="http://www.cs.princeton.edu/~diego/rfc/rfc2046.txt">RFC |
54 | 2046</a> | 56 | 2046</a> |
@@ -98,7 +100,7 @@ in representing them in a Lua table. | |||
98 | </p> | 100 | </p> |
99 | 101 | ||
100 | <p> | 102 | <p> |
101 | The following constants can be set to control the default behaviour of | 103 | The following constants can be set to control the default behavior of |
102 | the SMTP module: | 104 | the SMTP module: |
103 | </p> | 105 | </p> |
104 | 106 | ||
@@ -256,7 +258,7 @@ mesgt = { | |||
256 | to = "Fulano da Silva <fulano@example.com>", | 258 | to = "Fulano da Silva <fulano@example.com>", |
257 | cc = '"Beltrano F. Nunes" <beltrano@example.com>', | 259 | cc = '"Beltrano F. Nunes" <beltrano@example.com>', |
258 | subject = "My first message" | 260 | subject = "My first message" |
259 | } | 261 | }, |
260 | body = "I hope this works. If it does, I can send you another 1000 copies." | 262 | body = "I hope this works. If it does, I can send you another 1000 copies." |
261 | } | 263 | } |
262 | 264 | ||
diff --git a/doc/socket.html b/doc/socket.html index 1bbeb7f..129b134 100644 --- a/doc/socket.html +++ b/doc/socket.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: The core namespace"> |
7 | <meta name="keywords" content="Lua, Library, socket, Network, Support"> | ||
8 | <title>LuaSocket: The socket namespace</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -55,6 +57,16 @@ socket.<b>bind(</b>address, port [, backlog]<b>)</b> | |||
55 | </p> | 57 | </p> |
56 | 58 | ||
57 | <p class=description> | 59 | <p class=description> |
60 | This function is a shortcut that creates and returns a TCP server object | ||
61 | bound to a local <tt>address</tt> and <tt>port</tt>, ready to | ||
62 | accept client connections. Optionally, | ||
63 | user can also specify the <tt>backlog</tt> argument to the | ||
64 | <a href=tcp.html#listen><tt>listen</tt></a> method (defaults to 32). | ||
65 | </p> | ||
66 | |||
67 | <p class=note> | ||
68 | Note: The server object returned will have the option "<tt>reuseaddr</tt>" | ||
69 | set to <tt><b>true</b></tt>. | ||
58 | </p> | 70 | </p> |
59 | 71 | ||
60 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 72 | <!-- connect ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -64,9 +76,9 @@ socket.<b>connect(</b>address, port [, locaddr, locport]<b>)</b> | |||
64 | </p> | 76 | </p> |
65 | 77 | ||
66 | <p class=description> | 78 | <p class=description> |
67 | This function is a shortcut that creates and returns a TCP socket object | 79 | This function is a shortcut that creates and returns a TCP client object |
68 | connected to a remote <tt>host</tt> at a given <tt>port</tt>. Optionally, | 80 | connected to a remote <tt>host</tt> at a given <tt>port</tt>. Optionally, |
69 | the use can also specify the local address and port to bind | 81 | the user can also specify the local address and port to bind |
70 | (<tt>locaddr</tt> and </tt>locport</tt>). | 82 | (<tt>locaddr</tt> and </tt>locport</tt>). |
71 | </p> | 83 | </p> |
72 | 84 | ||
diff --git a/doc/tcp.html b/doc/tcp.html index 37b0b56..5c0da75 100644 --- a/doc/tcp.html +++ b/doc/tcp.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: The TCP/IP support"> |
7 | <meta name="keywords" content="Lua, Library, socket, TCP, Network, Support"> | ||
8 | <title>LuaSocket: TCP/IP support</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -74,7 +76,7 @@ reported by <b><tt>nil</tt></b> followed by a message describing the error. | |||
74 | </p> | 76 | </p> |
75 | 77 | ||
76 | <p class=note> | 78 | <p class=note> |
77 | Note: calling <a href=sockett.html#select><tt>socket.select</tt></a> | 79 | Note: calling <a href=socket.html#select><tt>socket.select</tt></a> |
78 | with a server object in | 80 | with a server object in |
79 | the <tt>receive</tt> parameter before a call to <tt>accept</tt> does | 81 | the <tt>receive</tt> parameter before a call to <tt>accept</tt> does |
80 | <em>not</em> guarantee <tt>accept</tt> will return immediately. Use the <a | 82 | <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. | |||
107 | </p> | 109 | </p> |
108 | 110 | ||
109 | <p class=note> | 111 | <p class=note> |
110 | Note: The function <a href=#socket.bind><tt>socket.bind</tt></a> | 112 | Note: The function <a href=socket.html#bind><tt>socket.bind</tt></a> |
111 | is available and is a shortcut for the creation server sockets. | 113 | is available and is a shortcut for the creation server sockets. |
112 | </p> | 114 | </p> |
113 | 115 | ||
@@ -163,15 +165,15 @@ describing the error. In case of success, the method returns 1. | |||
163 | </p> | 165 | </p> |
164 | 166 | ||
165 | <p class=note> | 167 | <p class=note> |
166 | Note: The function <a href=#socket.connect><tt>socket.connect</tt></a> | 168 | Note: The function <a href=socket.html#connect><tt>socket.connect</tt></a> |
167 | is available and is a shortcut for the creation of client sockets. | 169 | is available and is a shortcut for the creation of client sockets. |
168 | </p> | 170 | </p> |
169 | 171 | ||
170 | <p class=note> | 172 | <p class=note> |
171 | Note: Starting with LuaSocket 2.0, | 173 | Note: Starting with LuaSocket 2.0, |
172 | the <a href=#settimeout><tt>settimeout</tt></a> | 174 | the <a href=#settimeout><tt>settimeout</tt></a> |
173 | function affects the behavior of connect, causing it to return in case of | 175 | method affects the behavior of connect, causing it to return in case of |
174 | a timeout error. | 176 | a timeout. |
175 | </p> | 177 | </p> |
176 | 178 | ||
177 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 179 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -197,6 +199,7 @@ Note: It makes no sense to call this method on server objects. | |||
197 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 199 | <!-- getpeername ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
198 | 200 | ||
199 | <p class=name id=getsockname> | 201 | <p class=name id=getsockname> |
202 | master:<b>getsockname()</b><br> | ||
200 | client:<b>getsockname()</b><br> | 203 | client:<b>getsockname()</b><br> |
201 | server:<b>getsockname()</b> | 204 | server:<b>getsockname()</b> |
202 | </p> | 205 | </p> |
diff --git a/doc/udp.html b/doc/udp.html index 69895ce..75d1d9e 100644 --- a/doc/udp.html +++ b/doc/udp.html | |||
@@ -1,10 +1,14 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
2 | "http://www.w3.org/TR/html4/strict.dtd"> | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
3 | <html> | 3 | <html> |
4 | |||
4 | <head> | 5 | <head> |
5 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: The UDP support"> |
7 | <meta name="keywords" content="Lua, Library, socket, UDP, Network, Support"> | ||
8 | <title>LuaSocket: UDP support</title> | ||
6 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
7 | </head> | 10 | </head> |
11 | |||
8 | <body> | 12 | <body> |
9 | 13 | ||
10 | <!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 14 | <!-- header ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -14,7 +18,7 @@ | |||
14 | <center> | 18 | <center> |
15 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
16 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
17 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
18 | </a></td></tr> | 22 | </a></td></tr> |
19 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
20 | </td></tr> | 24 | </td></tr> |
@@ -240,7 +244,7 @@ unconnected:<b>setpeername(</b>address, port<b>)</b> | |||
240 | <p class="description"> | 244 | <p class="description"> |
241 | Changes the peer of a UDP object. This | 245 | Changes the peer of a UDP object. This |
242 | method turns an unconnected UDP object into a connected UDP | 246 | method turns an unconnected UDP object into a connected UDP |
243 | object or vice-versa. | 247 | object or vice versa. |
244 | </p> | 248 | </p> |
245 | 249 | ||
246 | <p class="description"> | 250 | <p class="description"> |
diff --git a/doc/url.html b/doc/url.html index 207995c..92acf36 100644 --- a/doc/url.html +++ b/doc/url.html | |||
@@ -3,7 +3,9 @@ | |||
3 | <html> | 3 | <html> |
4 | 4 | ||
5 | <head> | 5 | <head> |
6 | <title>LuaSocket: Network support for the Lua language</title> | 6 | <meta name="description" content="LuaSocket: URL manipulation"> |
7 | <meta name="keywords" content="Lua, Library, URL, link, Network, Support"> | ||
8 | <title>LuaSocket: URL support</title> | ||
7 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
8 | </head> | 10 | </head> |
9 | 11 | ||
@@ -16,7 +18,7 @@ | |||
16 | <center> | 18 | <center> |
17 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
18 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align=center><a href="http://www.lua.org"> |
19 | <img width=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> |
20 | </a></td></tr> | 22 | </a></td></tr> |
21 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align=center valign=top>Network support for the Lua language |
22 | </td></tr> | 24 | </td></tr> |
@@ -135,7 +137,7 @@ Rebuilds an URL from its parts. | |||
135 | <tt>Parsed_url</tt> is a table with same components returned by | 137 | <tt>Parsed_url</tt> is a table with same components returned by |
136 | <a href="#parse"><tt>parse</tt></a>. | 138 | <a href="#parse"><tt>parse</tt></a>. |
137 | Lower level components, if specified, | 139 | Lower level components, if specified, |
138 | take precedence over hight level components of the URL grammar. | 140 | take precedence over high level components of the URL grammar. |
139 | </p> | 141 | </p> |
140 | 142 | ||
141 | <p class=return> | 143 | <p class=return> |
@@ -279,8 +281,8 @@ Breaks a <tt><path></tt> URL component into all its | |||
279 | <p class=return> | 281 | <p class=return> |
280 | Since some characters are reserved in URLs, they must be escaped | 282 | Since some characters are reserved in URLs, they must be escaped |
281 | whenever present in a <tt><path></tt> component. Therefore, before | 283 | whenever present in a <tt><path></tt> component. Therefore, before |
282 | returning a list with all the parsed segments, the function unescapes all | 284 | returning a list with all the parsed segments, the function removes |
283 | of them. | 285 | escaping from all of them. |
284 | </p> | 286 | </p> |
285 | 287 | ||
286 | <!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 288 | <!-- unescape +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
diff --git a/samples/cddb.lua b/samples/cddb.lua index aefa04e..daa5df1 100644 --- a/samples/cddb.lua +++ b/samples/cddb.lua | |||
@@ -1,5 +1,5 @@ | |||
1 | socket = require("socket") | 1 | local socket = require("socket") |
2 | http = require("http") | 2 | local http = require("http") |
3 | 3 | ||
4 | if not arg or not arg[1] or not arg[2] then | 4 | if not arg or not arg[1] or not arg[2] then |
5 | print("luasocket cddb.lua <category> <disc-id> [<server>]") | 5 | print("luasocket cddb.lua <category> <disc-id> [<server>]") |
diff --git a/samples/daytimeclnt.lua b/samples/daytimeclnt.lua index b4075e9..6a26ffc 100644 --- a/samples/daytimeclnt.lua +++ b/samples/daytimeclnt.lua | |||
@@ -4,7 +4,7 @@ | |||
4 | -- Author: Diego Nehab | 4 | -- Author: Diego Nehab |
5 | -- RCS ID: $Id$ | 5 | -- RCS ID: $Id$ |
6 | ----------------------------------------------------------------------------- | 6 | ----------------------------------------------------------------------------- |
7 | require"socket" | 7 | local socket = require"socket" |
8 | host = host or "127.0.0.1" | 8 | host = host or "127.0.0.1" |
9 | port = port or 13 | 9 | port = port or 13 |
10 | if arg then | 10 | if arg then |
diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua index 73bf374..3ebbe85 100644 --- a/samples/echosrvr.lua +++ b/samples/echosrvr.lua | |||
@@ -4,7 +4,7 @@ | |||
4 | -- Author: Diego Nehab | 4 | -- Author: Diego Nehab |
5 | -- RCS ID: $Id$ | 5 | -- RCS ID: $Id$ |
6 | ----------------------------------------------------------------------------- | 6 | ----------------------------------------------------------------------------- |
7 | socket = require("socket") | 7 | local socket = require("socket") |
8 | host = host or "127.0.0.1" | 8 | host = host or "127.0.0.1" |
9 | port = port or 7 | 9 | port = port or 7 |
10 | if arg then | 10 | if arg then |
diff --git a/samples/talker.lua b/samples/talker.lua index bafd021..3f6e69c 100644 --- a/samples/talker.lua +++ b/samples/talker.lua | |||
@@ -4,7 +4,7 @@ | |||
4 | -- Author: Diego Nehab | 4 | -- Author: Diego Nehab |
5 | -- RCS ID: $Id$ | 5 | -- RCS ID: $Id$ |
6 | ----------------------------------------------------------------------------- | 6 | ----------------------------------------------------------------------------- |
7 | socket = require("socket") | 7 | local socket = require("socket") |
8 | host = host or "localhost" | 8 | host = host or "localhost" |
9 | port = port or 8080 | 9 | port = port or 8080 |
10 | if arg then | 10 | if arg then |
diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua index 85ebe29..13f42ec 100644 --- a/samples/tinyirc.lua +++ b/samples/tinyirc.lua | |||
@@ -4,7 +4,7 @@ | |||
4 | -- Author: Diego Nehab | 4 | -- Author: Diego Nehab |
5 | -- RCS ID: $Id$ | 5 | -- RCS ID: $Id$ |
6 | ----------------------------------------------------------------------------- | 6 | ----------------------------------------------------------------------------- |
7 | socket = require("socket") | 7 | local socket = require("socket") |
8 | host = host or "*" | 8 | host = host or "*" |
9 | port1 = port1 or 8080 | 9 | port1 = port1 or 8080 |
10 | port2 = port2 or 8181 | 10 | port2 = port2 or 8181 |
diff --git a/src/http.lua b/src/http.lua index 9c568bc..cdb435d 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -22,8 +22,6 @@ TIMEOUT = 60 | |||
22 | PORT = 80 | 22 | PORT = 80 |
23 | -- user agent field sent in request | 23 | -- user agent field sent in request |
24 | USERAGENT = socket.VERSION | 24 | USERAGENT = socket.VERSION |
25 | -- block size used in transfers | ||
26 | BLOCKSIZE = 2048 | ||
27 | 25 | ||
28 | ----------------------------------------------------------------------------- | 26 | ----------------------------------------------------------------------------- |
29 | -- Low level HTTP API | 27 | -- Low level HTTP API |
diff --git a/src/luasocket.h b/src/luasocket.h index 6d30605..35dc3d9 100644 --- a/src/luasocket.h +++ b/src/luasocket.h | |||
@@ -25,7 +25,10 @@ | |||
25 | /*-------------------------------------------------------------------------*\ | 25 | /*-------------------------------------------------------------------------*\ |
26 | * Initializes the library. | 26 | * Initializes the library. |
27 | \*-------------------------------------------------------------------------*/ | 27 | \*-------------------------------------------------------------------------*/ |
28 | #ifndef LUASOCKET_LIBNAME | ||
28 | #define LUASOCKET_LIBNAME "socket" | 29 | #define LUASOCKET_LIBNAME "socket" |
30 | #endif | ||
31 | |||
29 | LUASOCKET_API int luaopen_socket(lua_State *L); | 32 | LUASOCKET_API int luaopen_socket(lua_State *L); |
30 | 33 | ||
31 | #endif /* LUASOCKET_H */ | 34 | #endif /* LUASOCKET_H */ |
@@ -19,7 +19,10 @@ | |||
19 | #define MIME_API extern | 19 | #define MIME_API extern |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #ifndef MIME_LIBNAME | ||
22 | #define MIME_LIBNAME "mime" | 23 | #define MIME_LIBNAME "mime" |
24 | #endif | ||
25 | |||
23 | MIME_API int luaopen_mime(lua_State *L); | 26 | MIME_API int luaopen_mime(lua_State *L); |
24 | 27 | ||
25 | #endif /* MIME_H */ | 28 | #endif /* MIME_H */ |
diff --git a/src/mime.lua b/src/mime.lua index 345bd25..fcdc358 100644 --- a/src/mime.lua +++ b/src/mime.lua | |||
@@ -12,9 +12,9 @@ local mime = requirelib("mime", "luaopen_mime", getfenv(1)) | |||
12 | local ltn12 = require("ltn12") | 12 | local ltn12 = require("ltn12") |
13 | 13 | ||
14 | -- encode, decode and wrap algorithm tables | 14 | -- encode, decode and wrap algorithm tables |
15 | encodet = {} | 15 | mime.encodet = {} |
16 | decodet = {} | 16 | mime.decodet = {} |
17 | wrapt = {} | 17 | mime.wrapt = {} |
18 | 18 | ||
19 | -- creates a function that chooses a filter by name from a given table | 19 | -- creates a function that chooses a filter by name from a given table |
20 | local function choose(table) | 20 | local function choose(table) |
@@ -29,47 +29,47 @@ local function choose(table) | |||
29 | end | 29 | end |
30 | 30 | ||
31 | -- define the encoding filters | 31 | -- define the encoding filters |
32 | encodet['base64'] = function() | 32 | mime.encodet['base64'] = function() |
33 | return ltn12.filter.cycle(b64, "") | 33 | return ltn12.filter.cycle(b64, "") |
34 | end | 34 | end |
35 | 35 | ||
36 | encodet['quoted-printable'] = function(mode) | 36 | mime.encodet['quoted-printable'] = function(mode) |
37 | return ltn12.filter.cycle(qp, "", | 37 | return ltn12.filter.cycle(qp, "", |
38 | (mode == "binary") and "=0D=0A" or "\r\n") | 38 | (mode == "binary") and "=0D=0A" or "\r\n") |
39 | end | 39 | end |
40 | 40 | ||
41 | -- define the decoding filters | 41 | -- define the decoding filters |
42 | decodet['base64'] = function() | 42 | mime.decodet['base64'] = function() |
43 | return ltn12.filter.cycle(unb64, "") | 43 | return ltn12.filter.cycle(unb64, "") |
44 | end | 44 | end |
45 | 45 | ||
46 | decodet['quoted-printable'] = function() | 46 | mime.decodet['quoted-printable'] = function() |
47 | return ltn12.filter.cycle(unqp, "") | 47 | return ltn12.filter.cycle(unqp, "") |
48 | end | 48 | end |
49 | 49 | ||
50 | -- define the line-wrap filters | 50 | -- define the line-wrap filters |
51 | wrapt['text'] = function(length) | 51 | mime.wrapt['text'] = function(length) |
52 | length = length or 76 | 52 | length = length or 76 |
53 | return ltn12.filter.cycle(wrp, length, length) | 53 | return ltn12.filter.cycle(wrp, length, length) |
54 | end | 54 | end |
55 | wrapt['base64'] = wrapt['text'] | 55 | mime.wrapt['base64'] = wrapt['text'] |
56 | wrapt['default'] = wrapt['text'] | 56 | mime.wrapt['default'] = wrapt['text'] |
57 | 57 | ||
58 | wrapt['quoted-printable'] = function() | 58 | mime.wrapt['quoted-printable'] = function() |
59 | return ltn12.filter.cycle(qpwrp, 76, 76) | 59 | return ltn12.filter.cycle(qpwrp, 76, 76) |
60 | end | 60 | end |
61 | 61 | ||
62 | -- function that choose the encoding, decoding or wrap algorithm | 62 | -- function that choose the encoding, decoding or wrap algorithm |
63 | encode = choose(encodet) | 63 | mime.encode = choose(encodet) |
64 | decode = choose(decodet) | 64 | mime.decode = choose(decodet) |
65 | wrap = choose(wrapt) | 65 | mime.wrap = choose(wrapt) |
66 | 66 | ||
67 | -- define the end-of-line normalization filter | 67 | -- define the end-of-line normalization filter |
68 | function normalize(marker) | 68 | function mime.normalize(marker) |
69 | return ltn12.filter.cycle(eol, 0, marker) | 69 | return ltn12.filter.cycle(eol, 0, marker) |
70 | end | 70 | end |
71 | 71 | ||
72 | -- high level stuffing filter | 72 | -- high level stuffing filter |
73 | function stuff() | 73 | function mime.stuff() |
74 | return ltn12.filter.cycle(dot, 2) | 74 | return ltn12.filter.cycle(dot, 2) |
75 | end | 75 | end |
diff --git a/src/socket.lua b/src/socket.lua index 4d64651..b3889d7 100644 --- a/src/socket.lua +++ b/src/socket.lua | |||
@@ -8,7 +8,6 @@ | |||
8 | -- Load LuaSocket from dynamic library | 8 | -- Load LuaSocket from dynamic library |
9 | ----------------------------------------------------------------------------- | 9 | ----------------------------------------------------------------------------- |
10 | local socket = requirelib("luasocket", "luaopen_socket", getfenv(1)) | 10 | local socket = requirelib("luasocket", "luaopen_socket", getfenv(1)) |
11 | _LOADED["socket"] = socket | ||
12 | 11 | ||
13 | ----------------------------------------------------------------------------- | 12 | ----------------------------------------------------------------------------- |
14 | -- Auxiliar functions | 13 | -- Auxiliar functions |
@@ -31,7 +30,7 @@ function socket.bind(host, port, backlog) | |||
31 | sock:setoption("reuseaddr", true) | 30 | sock:setoption("reuseaddr", true) |
32 | local res, err = sock:bind(host, port) | 31 | local res, err = sock:bind(host, port) |
33 | if not res then return nil, err end | 32 | if not res then return nil, err end |
34 | backlog = backlog or 1 | 33 | backlog = backlog or 32 |
35 | res, err = sock:listen(backlog) | 34 | res, err = sock:listen(backlog) |
36 | if not res then return nil, err end | 35 | if not res then return nil, err end |
37 | return sock | 36 | return sock |
@@ -130,7 +130,7 @@ static int meth_setoption(lua_State *L) | |||
130 | static int meth_getfd(lua_State *L) | 130 | static int meth_getfd(lua_State *L) |
131 | { | 131 | { |
132 | p_tcp tcp = (p_tcp) aux_checkgroup(L, "tcp{any}", 1); | 132 | p_tcp tcp = (p_tcp) aux_checkgroup(L, "tcp{any}", 1); |
133 | lua_pushnumber(L, tcp->sock); | 133 | lua_pushnumber(L, (int) tcp->sock); |
134 | return 1; | 134 | return 1; |
135 | } | 135 | } |
136 | 136 | ||
@@ -164,6 +164,7 @@ static int meth_accept(lua_State *L) | |||
164 | p_tcp clnt = lua_newuserdata(L, sizeof(t_tcp)); | 164 | p_tcp clnt = lua_newuserdata(L, sizeof(t_tcp)); |
165 | aux_setclass(L, "tcp{client}", -1); | 165 | aux_setclass(L, "tcp{client}", -1); |
166 | /* initialize structure fields */ | 166 | /* initialize structure fields */ |
167 | sock_setnonblocking(&sock); | ||
167 | clnt->sock = sock; | 168 | clnt->sock = sock; |
168 | io_init(&clnt->io, (p_send)sock_send, (p_recv)sock_recv, &clnt->sock); | 169 | io_init(&clnt->io, (p_send)sock_send, (p_recv)sock_recv, &clnt->sock); |
169 | tm_init(&clnt->tm, -1, -1); | 170 | tm_init(&clnt->tm, -1, -1); |
@@ -310,10 +311,11 @@ static int global_create(lua_State *L) | |||
310 | if (!err) { | 311 | if (!err) { |
311 | /* allocate tcp object */ | 312 | /* allocate tcp object */ |
312 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); | 313 | p_tcp tcp = (p_tcp) lua_newuserdata(L, sizeof(t_tcp)); |
313 | tcp->sock = sock; | ||
314 | /* set its type as master object */ | 314 | /* set its type as master object */ |
315 | aux_setclass(L, "tcp{master}", -1); | 315 | aux_setclass(L, "tcp{master}", -1); |
316 | /* initialize remaining structure fields */ | 316 | /* initialize remaining structure fields */ |
317 | sock_setnonblocking(&sock); | ||
318 | tcp->sock = sock; | ||
317 | io_init(&tcp->io, (p_send) sock_send, (p_recv) sock_recv, &tcp->sock); | 319 | io_init(&tcp->io, (p_send) sock_send, (p_recv) sock_recv, &tcp->sock); |
318 | tm_init(&tcp->tm, -1, -1); | 320 | tm_init(&tcp->tm, -1, -1); |
319 | buf_init(&tcp->buf, &tcp->io, &tcp->tm); | 321 | buf_init(&tcp->buf, &tcp->io, &tcp->tm); |
@@ -208,7 +208,7 @@ static int meth_receivefrom(lua_State *L) | |||
208 | static int meth_getfd(lua_State *L) | 208 | static int meth_getfd(lua_State *L) |
209 | { | 209 | { |
210 | p_udp udp = (p_udp) aux_checkgroup(L, "udp{any}", 1); | 210 | p_udp udp = (p_udp) aux_checkgroup(L, "udp{any}", 1); |
211 | lua_pushnumber(L, udp->sock); | 211 | lua_pushnumber(L, (int) udp->sock); |
212 | return 1; | 212 | return 1; |
213 | } | 213 | } |
214 | 214 | ||
@@ -328,10 +328,10 @@ static int global_create(lua_State *L) | |||
328 | if (!err) { | 328 | if (!err) { |
329 | /* allocate tcp object */ | 329 | /* allocate tcp object */ |
330 | p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp)); | 330 | p_udp udp = (p_udp) lua_newuserdata(L, sizeof(t_udp)); |
331 | udp->sock = sock; | ||
332 | /* set its type as master object */ | ||
333 | aux_setclass(L, "udp{unconnected}", -1); | 331 | aux_setclass(L, "udp{unconnected}", -1); |
334 | /* initialize remaining structure fields */ | 332 | /* initialize remaining structure fields */ |
333 | sock_setnonblocking(&sock); | ||
334 | udp->sock = sock; | ||
335 | tm_init(&udp->tm, -1, -1); | 335 | tm_init(&udp->tm, -1, -1); |
336 | return 1; | 336 | return 1; |
337 | } else { | 337 | } else { |
diff --git a/src/usocket.c b/src/usocket.c index ea0f172..617b1ea 100644 --- a/src/usocket.c +++ b/src/usocket.c | |||
@@ -81,7 +81,6 @@ const char *sock_create(p_sock ps, int domain, int type, int protocol) | |||
81 | t_sock sock = socket(domain, type, protocol); | 81 | t_sock sock = socket(domain, type, protocol); |
82 | if (sock == SOCK_INVALID) return sock_createstrerror(errno); | 82 | if (sock == SOCK_INVALID) return sock_createstrerror(errno); |
83 | *ps = sock; | 83 | *ps = sock; |
84 | sock_setnonblocking(ps); | ||
85 | return NULL; | 84 | return NULL; |
86 | } | 85 | } |
87 | 86 | ||
@@ -178,10 +177,7 @@ const char *sock_accept(p_sock ps, p_sock pa, SA *addr, | |||
178 | do *pa = accept(sock, addr, addr_len); | 177 | do *pa = accept(sock, addr, addr_len); |
179 | while (*pa < 0 && errno == EINTR); | 178 | while (*pa < 0 && errno == EINTR); |
180 | /* if result is valid, we are done */ | 179 | /* if result is valid, we are done */ |
181 | if (*pa != SOCK_INVALID) { | 180 | if (*pa != SOCK_INVALID) return NULL; |
182 | sock_setnonblocking(pa); | ||
183 | return NULL; | ||
184 | } | ||
185 | /* find out if we failed for a fatal reason */ | 181 | /* find out if we failed for a fatal reason */ |
186 | if (errno != EWOULDBLOCK && errno != ECONNABORTED) | 182 | if (errno != EWOULDBLOCK && errno != ECONNABORTED) |
187 | return sock_acceptstrerror(errno); | 183 | return sock_acceptstrerror(errno); |
diff --git a/src/wsocket.c b/src/wsocket.c index 84a49dc..e276fe0 100644 --- a/src/wsocket.c +++ b/src/wsocket.c | |||
@@ -88,7 +88,6 @@ const char *sock_create(p_sock ps, int domain, int type, int protocol) | |||
88 | if (sock == SOCK_INVALID) | 88 | if (sock == SOCK_INVALID) |
89 | return sock_createstrerror(WSAGetLastError()); | 89 | return sock_createstrerror(WSAGetLastError()); |
90 | *ps = sock; | 90 | *ps = sock; |
91 | sock_setnonblocking(ps); | ||
92 | return NULL; | 91 | return NULL; |
93 | } | 92 | } |
94 | 93 | ||
@@ -177,10 +176,7 @@ const char *sock_accept(p_sock ps, p_sock pa, SA *addr, | |||
177 | /* try to get client socket */ | 176 | /* try to get client socket */ |
178 | *pa = accept(sock, addr, addr_len); | 177 | *pa = accept(sock, addr, addr_len); |
179 | /* if return is valid, we are done */ | 178 | /* if return is valid, we are done */ |
180 | if (*pa != SOCK_INVALID) { | 179 | if (*pa != SOCK_INVALID) return NULL; |
181 | sock_setnonblocking(pa); | ||
182 | return NULL; | ||
183 | } | ||
184 | /* optimization */ | 180 | /* optimization */ |
185 | if (timeout == 0) return io_strerror(IO_TIMEOUT); | 181 | if (timeout == 0) return io_strerror(IO_TIMEOUT); |
186 | /* otherwise find out why we failed */ | 182 | /* otherwise find out why we failed */ |
diff --git a/test/httptest.lua b/test/httptest.lua index ea8465d..3a4d461 100644 --- a/test/httptest.lua +++ b/test/httptest.lua | |||
@@ -4,11 +4,11 @@ | |||
4 | -- to "/luasocket-test-cgi" and "/luasocket-test-cgi/" | 4 | -- to "/luasocket-test-cgi" and "/luasocket-test-cgi/" |
5 | -- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth | 5 | -- needs "AllowOverride AuthConfig" on /home/c/diego/tec/luasocket/test/auth |
6 | 6 | ||
7 | socket = require("socket") | 7 | local socket = require("socket") |
8 | http = require("http") | 8 | local http = require("http") |
9 | mime = require("mime") | 9 | local mime = require("mime") |
10 | url = require("url") | 10 | local url = require("url") |
11 | ltn12 = require("ltn12") | 11 | local ltn12 = require("ltn12") |
12 | 12 | ||
13 | dofile("testsupport.lua") | 13 | dofile("testsupport.lua") |
14 | 14 | ||
diff --git a/test/mimetest.lua b/test/mimetest.lua index f51c3b8..685c610 100644 --- a/test/mimetest.lua +++ b/test/mimetest.lua | |||
@@ -8,7 +8,7 @@ local qptest = "qptest.bin" | |||
8 | local eqptest = "qptest.bin2" | 8 | local eqptest = "qptest.bin2" |
9 | local dqptest = "qptest.bin3" | 9 | local dqptest = "qptest.bin3" |
10 | 10 | ||
11 | local b64test = "luasocket.dll" | 11 | local b64test = "luasocket.dylib" |
12 | local eb64test = "b64test.bin" | 12 | local eb64test = "b64test.bin" |
13 | local db64test = "b64test.bin2" | 13 | local db64test = "b64test.bin2" |
14 | 14 | ||
diff --git a/test/stufftest.lua b/test/stufftest.lua index eddf636..490053f 100644 --- a/test/stufftest.lua +++ b/test/stufftest.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | mime = require("mime") | 1 | local mime = require("mime") |
2 | 2 | ||
3 | function test_dot(original, right) | 3 | function test_dot(original, right) |
4 | local result, n = mime.dot(2, original) | 4 | local result, n = mime.dot(2, original) |
diff --git a/test/testclnt.lua b/test/testclnt.lua index 1b20ad1..9aa07fe 100644 --- a/test/testclnt.lua +++ b/test/testclnt.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | socket = require"socket" | 1 | local socket = require"socket" |
2 | 2 | ||
3 | host = host or "localhost" | 3 | host = host or "localhost" |
4 | port = port or "8080" | 4 | port = port or "8080" |
@@ -418,7 +418,7 @@ function connect_errors() | |||
418 | assert(not c and e == "connection refused", e) | 418 | assert(not c and e == "connection refused", e) |
419 | print("ok") | 419 | print("ok") |
420 | io.stderr:write("host not found: ") | 420 | io.stderr:write("host not found: ") |
421 | local c, e = socket.connect("not.exist.com", 1); | 421 | local c, e = socket.connect("host.is.invalid", 1); |
422 | assert(not c and e == "host not found", e) | 422 | assert(not c and e == "host not found", e) |
423 | print("ok") | 423 | print("ok") |
424 | end | 424 | end |
diff --git a/test/testsrvr.lua b/test/testsrvr.lua index 5b842f1..71281cf 100644 --- a/test/testsrvr.lua +++ b/test/testsrvr.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | socket = require"socket" | 1 | local socket = require"socket" |
2 | 2 | ||
3 | host = host or "localhost" | 3 | host = host or "localhost" |
4 | port = port or "8080" | 4 | port = port or "8080" |
diff --git a/test/urltest.lua b/test/urltest.lua index 92f2fae..eb15bcf 100644 --- a/test/urltest.lua +++ b/test/urltest.lua | |||
@@ -1,4 +1,4 @@ | |||
1 | socket = require("socket") | 1 | local socket = require("socket") |
2 | socket.url = require("url") | 2 | socket.url = require("url") |
3 | dofile("testsupport.lua") | 3 | dofile("testsupport.lua") |
4 | 4 | ||