lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 19 November 2013 08:16, Sir Pogsalot <sir.pogsalot@gmail.com> wrote:
I had trouble trying to figure out luasocket from its documentation without resorting to digging through the source.  I understand that certain choices were made to unify the differences between how Linux and Windows error (as they use different constant names and values), but I found it frustrating figuring out what things like :receive() might return.  Maybe I'm just bad at navigating the docs, but I could not find a list of possible return values (the error names to compare against). :(

Have you seen the old official documentation at http://w3.impa.br/~diego/software/luasocket/reference.html
 
My reasoning for trying to match C structs is that there are a plethora of C networking tutorials and man pages detailing what to expect so it makes it very easy for others to figure out what values are in the table under what key names -- even if the table seems a bit wonky with how to how one would represent that data in Lua.  There are less Lua networking tutorials...
I once thought the same; then realised how much non-C programmers don't know about networking.
 
Your getaddrinfo() does look much nicer :]  I just couldn't decide on how to make it friendly -- how I would return a table showing which sock types and protocols the remote host supports.  Maybe people only really use getaddrinfo() to resolve domain names as they already know they want to establish a TCP connection.  My other reasoning was that because my bindings are pretty direct, it still leaves the option of layering over it a friendlier interface while not keeping things like getaddrinfo() from the user.
An issue with getaddrinfo is that there isn't a nice platform-independant asynchronous version.
 
With luasocket, I found a lot of the time I needed to break user-friendly abstractions.
Like what?