commit da9ccda24913353132344713a8d801909b26f0de
parent 4f679137f50e86ca302ee73aac88e71d15e95e2d
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 24 Jun 2021 13:29:11 -0400
net::unix: add dial implementation
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
4 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/net/unix/README b/net/unix/README
@@ -0,0 +1,4 @@
+net::unix provides access to Unix sockets for networking.
+
+A protocol provider for [[net::dial]] is provided by this module, but you must
+import net::unix at least once in order for it to be visible to net::dial.
diff --git a/net/unix/dial.ha b/net/unix/dial.ha
@@ -0,0 +1,14 @@
+use io;
+use net::dial;
+use net;
+
+fn dial_unix(addr: str, service: str) (*io::stream | dial::error) = {
+ return match (connect(addr)) {
+ conn: *io::stream => conn,
+ err: net::error => err,
+ };
+};
+
+@init fn registerproto() void = {
+ dial::registerproto("unix", &dial_unix);
+};
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -613,6 +613,7 @@ net_unix() {
gen_srcs net::unix \
'$(PLATFORM).ha' \
addr.ha \
+ dial.ha \
listener.ha \
options.ha
gen_ssa net::unix net errors os io strings types fmt
diff --git a/stdlib.mk b/stdlib.mk
@@ -902,6 +902,7 @@ $(HARECACHE)/net/udp/net_udp.ssa: $(stdlib_net_udp_srcs) $(stdlib_rt) $(stdlib_n
stdlib_net_unix_srcs= \
$(STDLIB)/net/unix/$(PLATFORM).ha \
$(STDLIB)/net/unix/addr.ha \
+ $(STDLIB)/net/unix/dial.ha \
$(STDLIB)/net/unix/listener.ha \
$(STDLIB)/net/unix/options.ha
@@ -2073,6 +2074,7 @@ $(TESTCACHE)/net/udp/net_udp.ssa: $(testlib_net_udp_srcs) $(testlib_rt) $(testli
testlib_net_unix_srcs= \
$(STDLIB)/net/unix/$(PLATFORM).ha \
$(STDLIB)/net/unix/addr.ha \
+ $(STDLIB)/net/unix/dial.ha \
$(STDLIB)/net/unix/listener.ha \
$(STDLIB)/net/unix/options.ha