Commit Graph

67 Commits

Author SHA1 Message Date
E. Westbrook
d71e6bc459 udp: pragma visibility 2019-03-10 00:04:20 -07:00
Mojca Miklavec
d9afe3fd9c Only use EAI_OVERFLOW, AI_NUMERICSERV if defined
Some systems like Mac OS X 10.5 (and lower) do not have EAI_OVERFLOW and
AI_NUMERICSERV defined.

These variables are used to avoid a potentially slow name resolution
for the hostname (which will always be an ip address)
and for service name (which will always be an actual port number).

The code might be slower, but it should still work.

Closes: #242
2019-02-26 09:30:15 +01:00
E. Westbrook
30a0a6003b udp.c: use LUASOCKET_PRIVATE 2019-02-25 16:01:21 -07:00
surenyi
97bfe1e043 add options:
get/set : recv-buffer-size
get/set : send-buffer-size

Signed-off-by: surenyi <surenyi82@163.com>
2018-03-25 14:58:10 +08:00
Natanael Copa
3041a808c3 Create socket on first sendto if family agnostic udp() was used
Create socket and set family on first sendto() if udp() was created
without address family.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2017-01-25 12:52:56 +01:00
Diego Nehab
944305dc21 Added gettimeout for completeness.
Also documented.
Rordered manuals so order is alphabetical.
2016-03-04 15:36:32 -03:00
Diego Nehab
be67f63f4e Changed buffer-per-socket to buffer-per-operation.
This is a difficult tradeoff to measure. I think large
datagrams won't be used very frequently. So it is better to
not lock a large buffer to each socket object and instead
allocate and deallocate for each operation receiving a
datagram larger than UDP_DATAGRAMSIZE.
2015-10-06 11:33:50 +08:00
Diego Nehab
fd729b32a8 Added support for arbitrary datagram sizes.
The maximum size is still constant per UDP object, but the
size can be speficied at creation time.
2015-10-05 11:47:51 +08:00
Diego Nehab
77bba625d7 Fixes suggested by @Florob in #147. 2015-08-25 15:41:40 -03:00
Diego Nehab
96965b179c New agnostic IPv4 IPv6 functions.
Also dealing with EPROTOTYPE Yosemite seems to be throwing
at us for no reason.
2015-08-22 19:52:01 -03:00
Diego Nehab
9322eacefd Merge pull request #141 from cjtallman/master
Added missing options for UDP getoption.
2015-08-21 15:51:52 -03:00
Diego Nehab
e75444ccd1 New compat.h module implements luaL_setfuncs.
Makes initialization code simpler everywhere.
2015-08-21 15:39:34 -03:00
cjtallman
67abaf89eb Added missing options for UDP getoption.
Documentation says "dontroute", "broadcast", "reuseaddr", and
"reuseport" are supported as arguments to getoption, however their
implementations were missing.
2015-06-11 09:02:20 -07:00
Stephan Gatzka
c6f136c7f5 Make local function udp_strerror() static. 2014-12-21 07:44:11 +01:00
unknown
5eefc73b57 Remove warnings. Move windows specific code. 2013-05-30 16:50:28 +08:00
Diego Nehab
a233e27865 Leaving if in src/ but out of build for now. 2013-05-30 16:20:34 +08:00
moteus
1de617e355 Add. Allow get error option to socket. 2013-05-29 14:33:27 +04:00
Diego Nehab
79e6c4915d Export global only if LUA_COMPAT_MODULE defined. 2013-05-29 16:56:56 +08:00
Diego Nehab
27fd725c6d Typo fixed. 2013-05-28 01:54:49 +08:00
unknown
734cc23e1f Fixed inet_pton and a new Winsock UDP bug.
inet_pton was copying the entire sockaddr_in struct,
rather than just the sin_addr field...

I am a bit unsure about the UDP fix, because it may affect
TCP as well. On UDP sockets, when a sendto fails, the next
receive/receivefrom fails with CONNRESET. I changed
sock_recv/sock_recvfrom in wsocket.c to skip the CONNRESET
from the recv/recvfrom, hoping that if the socket is TCP,
sock_waitfd will get the CONNRESET again. The tests pass,
but this should be tested more thoroughly.
2013-05-28 00:09:30 +08:00
unknown
66cd8cfcee Fix wrong usage of inet_pton. 2013-05-27 22:17:51 +08:00
Diego Nehab
427220c7b1 Merge tryconnect6 into inet_tryconnect. 2013-05-26 21:26:26 +08:00
unknown
bb0b31301a Add MingW support. 2013-05-25 18:07:38 +08:00
Diego Nehab
72a5347f97 Remove warnings and fix makefile for Win32. 2012-12-11 17:43:49 -02:00
Diego Nehab
6368caeb5a Fix udp:setpeername("*")
There seems to be a curious difference between MacOS and
Linux and I am not sure if this is documented. When you
break a "connection" on Mac OS, you only eliminate the peer
association, but the local address remains bound. On Linux,
breaking a "connection" eliminates the binding to the local
address. Have you guys ever come accross this?

Another irritating difference is that connect() returns the
error EAFNOSUPPORT on Mac OS. I am going to ignore all
errors when the reason for calling connect() is simply to
break the "connection".
2012-08-23 19:31:15 -03:00
Florian Zeitz
7503bb0ca3 Add IPv6 support to udp:receivefrom() 2012-07-18 21:05:30 +02:00
Florian Zeitz
a6cf48596d Add IPv6 support to udp:sendto() 2012-07-17 19:02:20 +02: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
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
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
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
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
Florian Zeitz
594f826aa1 Add support for connecting to IPv6 hosts 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
923eef1929 Rework binding IPv6 sockets by harmonizing it with the IPv4 variant 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
Diego Nehab
2778766d67 Preliminary IPv6 support for v2.1 2012-04-11 13:25:11 -07:00
Diego Nehab
bce60be30f Decent makefiles! 2009-05-27 09:31:38 +00:00
Diego Nehab
f4dadea763 Before compiling on Windows. 2005-10-07 04:40:59 +00:00
Diego Nehab
a32c6d9140 Almost ready to release. 2005-09-29 06:11:42 +00:00
Diego Nehab
5e75dc0857 Wrong class... 2005-04-13 22:18:21 +00:00
Diego Nehab
7c97e8e40a Almost ready for beta3 2004-11-27 07:58:04 +00:00
Diego Nehab
9a79d500eb Still need to fix windows. :o/ 2004-07-15 06:11:53 +00:00
Diego Nehab
7115c12fbc Moving on to beta2. 2004-07-01 03:32:09 +00:00
Diego Nehab
bce1cb30d8 More adjustments/bugfixes. 2004-06-21 06:07:58 +00:00
Diego Nehab
680473dd32 Runs on Linux. 2004-06-15 20:05:23 +00:00
Diego Nehab
58096449c6 Manual is almost done. HTTP is missing.
Implemented new distribution scheme.
Select is now purely C.
HTTP reimplemented seems faster dunno why.
LTN12 functions that coroutines fail gracefully.
2004-06-15 06:24:00 +00:00
Diego Nehab
9ed7f955e5 Só pra não perder se der merda. 2004-06-04 15:15:45 +00:00
Diego Nehab
c98dc99199 Bug feioso no UDP e possivelmente no TCP também. 2004-05-28 07:24:43 +00:00
Diego Nehab
888496aa82 FTP low-level working.
SMTP connection oriented working.
ltn12 improved.
2004-05-25 05:27:44 +00:00