summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-08-26 15:05:41 -0400
committerOri Bernstein <ori@eigenstate.org>2014-08-26 15:05:41 -0400
commit76c13fb5d6c1ba31a4d930e3db5f5466f263f6fb (patch)
tree4c5403bebb2ce3e21f089915e8fd7aa6e959fd4d
parent791c39b9e378c3ce189dce1119c272b66393e6a0 (diff)
downloadlibbio-76c13fb5d6c1ba31a4d930e3db5f5466f263f6fb.tar.gz
Add dial() to bio.
-rw-r--r--bio.myr9
1 files changed, 9 insertions, 0 deletions
diff --git a/bio.myr b/bio.myr
index 74da64d..298f1f5 100644
--- a/bio.myr
+++ b/bio.myr
@@ -24,6 +24,7 @@ pkg bio =
/* creation */
const mkfile : (fd : std.fd, mode : mode -> file#)
const open : (path : byte[:], mode : mode -> std.option(file#))
+ const dial : (srv : byte[:], mode : mode -> std.option(file#))
const create : (path : byte[:], mode : mode, perm : int -> std.option(file#))
const close : (f : file# -> bool)
@@ -95,6 +96,14 @@ const create = {path, mode, perm
-> sysopen(path, mode, sysmode(mode) | std.Ocreat, perm)
}
+/* dial the server, and open a file using the returned fd */
+const dial = {srv, mode
+ match std.dial(srv)
+ | `std.Ok sock: -> `std.Some mkfile(sock, mode)
+ | `std.Fail _: -> `std.None
+ ;;
+}
+
/* map from the bio modes to the unix open modes */
const sysmode = {mode
match mode