Commit Graph

253 Commits

Author SHA1 Message Date
Paul Aurich
d777341eaf tcp: Initialize clnt->family in :accept()
Also unconditionally zero out the structs when allocated, for
good measure.
2012-05-21 19:44:08 -07:00
Diego Nehab
05535a19f8 Improve makefile to allow overriden variables
Before this change, it was difficult to set default
directories for different platforms that would still
work with different Lua versions.
2012-05-11 15:33:47 +08:00
Sam Roberts
156669c28b socket.connect now implemented in the C core
This avoid socket.lua duplicating the iteration over the results
of getaddrinfo(). Some problems with the C implementation not
initializing sockets or the luasocket family have also been fixed,
and error reporting made more robust.
2012-05-10 14:14:22 -07:00
Diego Nehab
3d3e69c6e4 Merge pull request #8 from sam-github/fix-confusing-servname-reference
Reword error msg to distinguish between service and server
2012-05-08 11:52:23 -07:00
Diego Nehab
1bb586d655 Merge pull request #7 from sam-github/fix-makefiles
Rework makefiles to simplify setting and choosing build options.
2012-05-08 11:51:25 -07:00
Sam Roberts
ac59bcbeac Reword error msg to distinguish between service and server
servname is easily confused with "server name", making it seem
as if the server name couldn't be resolved.
2012-05-08 10:55:33 -07:00
Sam Roberts
c291383ce2 Rework makefiles to simplify setting and choosing build options.
Includes documentation for common build settings, reasonable
defaults, and ability to set common build options in the
environment.
2012-05-08 10:51:56 -07:00
Florian Zeitz
0c3e067af1 Add a getnameinfo() wrapper
This wrapper takes a domain name or an IP as first argument
and a service name or port as second argument.
Either argument may be nil.

It returns a list of names (always only one in the IP case) and a
service name.
2012-05-05 02:13:56 +02:00
Sam Roberts
e86eac96fa :shutdown() errors on all invalid argument strings
It used to error only on invalid argument strings that started with 's',
'r', or 'b'.
2012-04-26 16:50:27 -07:00
Diego Nehab
c2e29537f5 Fixed getpeername/getsockname situation
- Added IPv6 support to getsockname
- Simplified getpeername implementation
- Added family to return of getsockname and getpeername
and added modification to the manual to describe
2012-04-24 00:47:30 +08:00
Diego Nehab
1acf8188cd socket.bind also tries all addresses returned by getaddrinfo. 2012-04-23 01:40:31 +08:00
Diego Nehab
966642f76a socket.connect() loops over addresses returned by getaddrinfo 2012-04-23 01:29:41 +08:00
Diego Nehab
f960b3872a Making progress toward a release
Documented headers.lua
Update copyright date everywhere
Remove RCSID from files
Move version back to 2.1 rather than 2.1.1
Fixed url package to support ipv6 hosts
Changed "domain" to "family" in tcp and udp structures
Implemented getfamily methods
2012-04-23 00:18:45 +08:00
Diego Nehab
f37e026026 First stab at documenation
Update Lua and Luasocket version in samples and in documentation
Documented ipv5_v6only default option being set
Documented tcp6 and udp6
Documented dns.getaddrinfo
Documented zero-sized datagram change?
Documented getoption
2012-04-17 01:15:26 +08:00
Diego Nehab
b3c4f46179 merged lua_typerrror.{c,h} into auxiliar.{c,h} 2012-04-16 20:41:48 +08:00
Sam Roberts
4b671f4551 Merge branch 'git-sam' into diego-sam-mwild-integration
Conflicts in options.c were just due to independent small functions
being close to each other.

unix.c in mwild was broken, it wasn't using LUASOCKET_API.

serial.c needed luaL_reg renamed, and to use LUASOCKET_API.

makefile didn't respect standard DESTDIR and prefix makefile
variables, and didn't allow LUAV variable to select lua version to build
against.

I've tested the top-level install-both target builds and installs
against both lua5.1 and lua5.2, but not done further testing.

Conflicts:
	README
	config
	gem/ltn012.tex
	makefile
	src/makefile
	src/options.c
	src/options.h
	src/tcp.c
	src/usocket.c
2012-04-11 14:18:20 -07:00
Sam Roberts
8bb542baaf Support getoption method for tcp objects. 2012-04-11 13:54:01 -07:00
Sam Roberts
0716cb868e Bounds check the argument to FD_SET
Failing to check the FD_SET argument against FD_SETSIZE causes
undefined behaviour (segfaults, for example).
2012-04-11 13:54:01 -07:00
Sam Roberts
27a3964ff7 socket_strerror() sometimes maps errno, instead of its argument
Looks like a historical bug. Its err argument is an error number, but
if it isn't using a custom error message for it, it just calls
strerror() with the errno global, effectively ignoring its argument
and returning a semi-random string.
2012-04-11 13:54:01 -07:00
root
e716e7347b mime: Remove io dependency
This dependency was spuriously added, maybe for debug reasons,
as confirmed to me by Diego Nehab by mail.
Some systems based in Lua (e.g. Ginga) prohibit the use of
io module for security reasons, so this dependency makes
mime unusable; even worse this makes other modules, based
on mime, unusable too (e.g. html).
2012-04-11 13:45:59 -07:00
Sam Roberts
b1f7c349b5 Add support for serial devices as socket streams on unix. 2012-04-11 13:45:59 -07:00
Sam Roberts
f63d616bc0 Use poll by default for socket.connect(), instead of select().
Connect timeouts are implemented by waiting on the new socket
descriptor. When select() is used for this, it imposes an arbitrary
limit on the number of connections that can be made, usually 1024-3.
Using poll() removes this limit on the number of simultaneous TCP
connections can be made using luasocket. The previous default
implementation using select() is available by defining SOCKET_SELECT.
Note that using socket.select() always uses select(), so it isn't
possible to wait on an arbitrary number of connections at once.
2012-04-11 13:45:59 -07:00
Sam Roberts
21698c7665 Receive of zero for UDP is now possible.
Previously, receive of zero was considered to be "closed", but that
is only true for stream-based protocols, like TCP.
2012-04-11 13:45:59 -07:00
Sam Roberts
51acb54760 Stop returning an error after successful send of zero length UDP packets
A zero-length send is invalid with TCP, but well defined with UDP.
udp:send"" was returning (nil,"refused"), indicating that it failed when
the packet was actually sent. The test script reproduces the bug, and
includes a tcpdump of the zero length packet being sent.
2012-04-11 13:45:59 -07:00
Sam Roberts
1f704cfb89 Add all-unix and install-unix targets which include all modules supported on unix.
Besides standard socket and mime modules, this includes unix domain
socket support.
2012-04-11 13:45:59 -07:00
Florian Zeitz
f399ab25fc inet: Honor the strict aliasing rule 2012-04-11 13:33:35 -07:00
Liam Devine
e81a6ff623 Conditional creation of p_timeout instance 'tm' 2012-04-11 13:33:34 -07:00
Liam Devine
c8eed36788 This is a replacement for luaL_typerror , removed from Lua 5.2, which corrects the spelling.
NOTE:
There is one failing test in.the /test/testsrvr.lua and /test/testclnt.lua combination which was present in the repo I cloned from.
2012-04-11 13:33:34 -07:00
Liam Devine
e15ed19db6 Compiles with Lua 5.1.4 and Lua 5.2.0-beta, although the makefile needs sorting out to take maybe a version number and also the local paths need removing. 2012-04-11 13:33:34 -07:00
Paul Aurich
a984607f28 inet: return more useful errors 2012-04-11 13:33:34 -07:00
Paul Aurich
7893d9ece2 inet: refactor getpeername to allocate the struct on the stack 2012-04-11 13:33:34 -07:00
Florian Zeitz
8393c76180 Fix getpeername to work with IPv6 addresses 2012-04-11 13:33:34 -07:00
Florian Zeitz
594f826aa1 Add support for connecting to IPv6 hosts 2012-04-11 13:33:34 -07:00
Florian Zeitz
5874d47f55 dns.getaddrinfo: Return proper error messages 2012-04-11 13:33:34 -07:00
Florian Zeitz
f871a29f27 Add support for the IPV6_V6ONLY socket option defaulting to on. 2012-04-11 13:33:34 -07:00
Florian Zeitz
4df1618aab Adapt socket.bind() to create a IPv4 or IPv6 depending on the address given 2012-04-11 13:33:34 -07:00
Florian Zeitz
5065a2585c dns: Rename toip6() to getaddrinfo() since the old name is misleading 2012-04-11 13:33:34 -07:00
Florian Zeitz
923eef1929 Rework binding IPv6 sockets by harmonizing it with the IPv4 variant 2012-04-11 13:33:34 -07:00
Matthew Wild
5c33ef9997 url.escape/url.unescape: Fix to return *only* the encoded/decoded string (thanks moodydeath) 2012-04-11 13:33:34 -07:00
Paul Aurich
908ee2cce1 Fix two crashes and add -Wshadow so that this can't happen again.
The two crashes are the s/const char *// changes in tcp.c.  The rest
is cleanup so it will build.
2012-04-11 13:33:34 -07:00
Matthew Wild
dd83e0a849 #ifdef EAI_BADHINTS and EAI_PROTOCOL which don't seem available on my system (Linux/glibc 2.11) 2012-04-11 13:33:34 -07:00
Diego Nehab
2778766d67 Preliminary IPv6 support for v2.1 2012-04-11 13:25:11 -07:00
Diego Nehab
3a8ba90dfb Saving before big changes to support IPv6. 2011-05-25 20:57:22 +00:00
Diego Nehab
bce60be30f Decent makefiles! 2009-05-27 09:31:38 +00:00
Diego Nehab
d1a72435d5 New release. 2007-10-13 23:55:20 +00:00
Diego Nehab
e394956cde Global variable references. 2007-07-11 19:25:47 +00:00
Diego Nehab
3cd10f5ab6 Crashy bug fixed in recvraw.
Also fixed returns on closed socket.
2007-06-11 23:44:54 +00:00
Diego Nehab
be2e467929 Couple bug fixes. 2007-03-12 04:08:40 +00:00
Diego Nehab
75f51d5bc7 Almost ready to release 2.0.1 2006-04-20 04:16:23 +00:00
Diego Nehab
e8650bbf16 http.request was using old host header during redirects. 2006-04-13 07:00:24 +00:00