summaryrefslogtreecommitdiffstats
path: root/stdlib/socket.tl
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/socket.tl')
-rw-r--r--stdlib/socket.tl9
1 files changed, 9 insertions, 0 deletions
diff --git a/stdlib/socket.tl b/stdlib/socket.tl
index 80a60ec5..af4aca4e 100644
--- a/stdlib/socket.tl
+++ b/stdlib/socket.tl
@@ -279,3 +279,12 @@
(,setter (val)
^(sock-set-opt ,',sock ,',level ,',option ,val ,',type)))
,body)))
+
+(defun sockaddr-str (str)
+ (cond
+ ((starts-with "[" str) (in6addr-str str))
+ ((starts-with "/" str) (new sockaddr-un path str))
+ ((contains "::" str) (in6addr-str str))
+ ((contains "." str) (inaddr-str str))
+ (t (or (ignerr (in6addr-str str))
+ (inaddr-str str)))))