lua-users home
lua-l archive

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


1) Well yes :]  I had seen this: http://w3.impa.br/~diego/software/luasocket/tcp.html#receive

I was trying to find a list of errors that it might throw back at me?  I swear I must be missing it somewhere... halp?

2) Well that was my justification for wanting to make it little guess-work to understand a C tutorial in Lua...  Gotta start somewhere :]

3) Linux has a lovely getaddrinfo_a() that does lookups in parallel... you could start multiple worker threads with something like lua-lanes to do individual getaddrinfo()'s but that's a lot of responsibility/liability on you... I wish getaddrinfo_a() were portable XD

4) Okay, maybe I only wanted to break abstractions for using different polling interfaces/APIs.  :getfd() was hard, lol.  (j/k)  The more I dug into the source for luasocket the more I wanted to create my own binding.  I think what Diego did is great, but there's a lot of code in there done for efficiency (he has his own buffer object).  I try tried to write as little as possible so as to avoid introducing my own unexpected behavior -- but I'm not implying luasocket isn't well-written.  I just wanted to use what was already there like luaL_Buffer to copy out from recv() and such.


On Tue, Nov 19, 2013 at 8:26 AM, Daurnimator <quae@daurnimator.com> wrote:
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?