lua-users home
lua-l archive

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


Hello Sean Conner and Francisco Olarte,

Maybe luasocket doesn't support DGRAM by default. It only supports STREAM for UDS..

Thank you!

Be careful for the corona19. In Korea, everyone wear masks and don't get together if not inevitable.

Jeonghum


2020년 3월 31일 (화) 오후 4:55, Sean Conner <sean@conman.org>님이 작성:
It was thus said that the Great Francisco Olarte once stated:
> Jeonghum:
>
> On Tue, Mar 31, 2020 at 3:41 AM Jeonghum Joh <oosaprogrammer@gmail.com> wrote:
> > I am investigating UDP Unix Domain Socket APIs in luasocket.
> ...
> > Diego Nehab provided TCP Unix Domain Socket sample code and I tested it successfully. I appreciate him for this email.
>
> Unix domain sockets do not support UDP or TCP, they support Datagram
> or Stream sockets. UDP and TCP are the datagram sockets for IP. Also,
> on some places, unix domain sockets support sequence datagram ( which
> is a mix, message oriented but reliable and ordered ) ( man 7 unix
> could help ).
>
> That being said, I'm not a luasocket, but this intrigued me, I had a
> look at the source and it seems it just opens them in SOCK_STREAM
> mode. Add to this the existence of different C source files for tcp
> and udp ( and unix ) and it seems you just have SOCK_STREAM and
> SOCK_DGRAM in AF_INET ( tcp and udp ) and SOCK_STREAM in AF_UNIX (
> byte stream unix sockets ).

  To clarify things a bit [1], you create either a SOCK_STREAM or SOCK_DGRAM
[2], then bind it to an address.  The address can either be a Unix domain,
in the IP domain (IPv4) or IPv6 domain.  It maps out as:

        Family  SOCK_STREAM     SOCK_DGRAM
        -----------------------------------
        Unix    stream          datagram
        IP      TCP             UDP
        IPv6    TCP             UDP

  You can have Unix domain sockets with datagrams.  How you create these in
luasocket I don't know as I don't use it, but it should be possible.

  -spc

[1]     I don't use luasocket, but my own module:

        https://github.com/spc476/lua-conmanorg/blob/master/src/net.c

[2]     There are other types but they're not important right now.