It had this field at latest since "Tue May 24 10:09:53 1994 UTC",
according to FreeBSD's svn repo so this isn't a new thing in need of
version detection.
Signed-off-by: Giel van Schijndel <me@mortis.eu>
I.e. taking a Unix sockaddr's maximum size, subtracting the one variable
field's max size and adding the size of that field's content gets us the
actual size anytime. This gives us less duplication and only a single
piece of code used across all Unices: i.e. the same code gets tested on
all.
In particular the current makefile, when used on FreeBSD (which *does*
have the sun_len field, but appears to ignore its contents) the
addr-length passed to connect() and bind() is one to small because the
sun_len field's space is neglected in the previous size computation.
This change removes the unnecessary dependency on the build system for
the correctness of the addr length computation.
Signed-off-by: Giel van Schijndel <me@mortis.eu>
In this example:
>Client send: MDTM test.txt
>Server response: 213 20120824120909
Because FTP server do not open new channel (2XX response)
and LuaSocket try open new channel we get timeout.
```lua
local ftp = require "socket.ftp"
local ltn12 = require "ltn12"
local url = require("socket.url")
local URL = "ftp://USER:TEST@127.0.0.1";
local CMD = 'MDTM test.txt';
-- get timeout
ftp.get{
url = URL;
command = CMD;
sink = ltn12.sink.table{};
}
-- or we can use ftp.command
ftp.command{
url = URL;
command = URL,
check = function(...)
local status, data = ...
return true
end;
}
```
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.