lua-users home
lua-l archive

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


On Tue, Mar 31, 2020 at 9:55 AM Sean Conner <> wrote:
>   To clarify things a bit [1], you create either a SOCK_STREAM or SOCK_DGRAM
> [2], then bind it to an address.

I may be getting it wrong, but I think you create a socket of a family
( AF_INET, AF_UNIX ) and a type ( SOCK_STREAM, SOCK_DGRAM ), then
bind it (or connect) to an address of the same family ( actually,
IIRC, bind is always optional in TCP, you can just connect and let the
system pick a local address ( the usual on outgoing connections), bind
to a local address and then (try to) connect, bind to a known local
address and listen to remote connections ( the usual ) or just listen
and let the system pick a free transport address ( typically a port
and any address) for you ( which you'll need to communicate somehow to
the remote side, but has its uses ).

I'm disgressing. What I wanted to point is bind/listen/connect do not
select the socket type, they also select the family ( unix/ip) and
bind is constrained by the socket.

Francisco Olarte.