netcat: Local socket support

Ingo van Lil inguin at gmx.de
Wed Apr 22 22:33:01 UTC 2009


Denys Vlasenko schrieb:

> Unfortunately, you patched nc.c instead of nc_bloaty.c,
> and nc_bloaty.c is supposed to have "all bells and whistles"
> and be compatible, not "small" nc.c

Well, I needed the feature on an embedded system, so enabling
CONFIG_DESKTOP just to get nc_bloaty.c instead of nc.c didn't seem like
an option.

> Adding 128-byte struct sockaddr_un to len_and_sockaddr like this:
> 
> [...]
> 
> will bloat stack and other data for many unrelated applets.
> Since you malloc your lsa, you can work around this.

Good point. Being able to directly access the sockaddr_un fields without
casting is convenient, but it's probably not worth the overhead in
unrelated places.
The xzalloc_lsa() helper from inetd.c might be a good candidate to make
allocating a proper address structure for a given protocol family a
little more convenient, though.

> Connecting to UNIX domain socket like this:
> 
> [...]
> 
> defeats the whole purpose of len_and_sockaddr data type
> and create_and_connect_stream_or_die(name, port) function,
> which is _supposed_ to_ derive the type of socket
> (AF_INET? AF_INET6? AF_UNIX?...) by looking at its arguments.

OK, I see. I misinterpreted the presence of the "port" parameter as a
sign that the function was meant to be TCP-only.

I like the idea with the "local:" address prefix; I'll give it a try
within the next couple of days. Would you prefer support for those
addresses to be an optional feature or unconditionally enabled? And what
about the listen side? How would that be handled universally (inetd
might benefit from that)?

Cheers,
Ingo


More information about the busybox mailing list