aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2011-06-17 13:51:34 -0700
committerSam Roberts <vieuxtech@gmail.com>2012-04-11 13:45:59 -0700
commit51acb54760dc91095d59839e8ea2256557f42781 (patch)
tree080967bc57ac420d8654e2652a14c5499fd0467f /test
parenta8b19e5367738f606a051f254858dc09de2a695a (diff)
downloadluasocket-51acb54760dc91095d59839e8ea2256557f42781.tar.gz
luasocket-51acb54760dc91095d59839e8ea2256557f42781.tar.bz2
luasocket-51acb54760dc91095d59839e8ea2256557f42781.zip
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.
Diffstat (limited to 'test')
-rwxr-xr-xtest/udp-zero-length-send25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/udp-zero-length-send b/test/udp-zero-length-send
new file mode 100755
index 0000000..a594944
--- /dev/null
+++ b/test/udp-zero-length-send
@@ -0,0 +1,25 @@
1#!/usr/bin/lua
2
3--[[
4Show that luasocket returns an error message on zero-length UDP sends,
5even though the send is valid, and in fact the UDP packet is sent
6to the peer:
7
8% sudo tcpdump -i lo -n
9tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
10listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
1113:40:16.652808 IP 127.0.0.1.56573 > 127.0.0.1.5432: UDP, length 0
12
13]]
14
15require"socket"
16
17s = assert(socket.udp())
18r = assert(socket.udp())
19assert(r:setsockname("*", 5432))
20assert(s:setpeername("127.0.0.1", 5432))
21
22ssz, emsg = s:send("")
23
24print(ssz == 0 and "OK" or "FAIL",[[send:("")]], ssz, emsg)
25