summaryrefslogtreecommitdiff
path: root/src/libs6rc/s6rc_connection_start.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs6rc/s6rc_connection_start.c')
-rw-r--r--src/libs6rc/s6rc_connection_start.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_connection_start.c b/src/libs6rc/s6rc_connection_start.c
new file mode 100644
index 0000000..33b2b1a
--- /dev/null
+++ b/src/libs6rc/s6rc_connection_start.c
@@ -0,0 +1,22 @@
+/* ISC license. */
+
+#include <skalibs/djbunix.h>
+#include <skalibs/webipc.h>
+#include <skalibs/textmessage.h>
+
+#include <s6-rc/connection-common.h>
+#include <s6-rc/connection.h>
+
+int s6rc_connection_start (s6rc_connection_t *a, char const *path, tain_t const *deadline, tain_t *stamp)
+{
+ int fd = ipc_stream_nbcoe() ;
+ if (fd < 0) return 0 ;
+ if (!ipc_timed_connect(fd, path, deadline, stamp))
+ {
+ fd_close(fd) ;
+ return 0 ;
+ }
+ textmessage_sender_init(&a->out, fd) ;
+ textmessage_receiver_init(&a->in, fd, a->inbuf, S6RC_CONNECTION_BUFSIZE, TEXTMESSAGE_MAXLEN) ;
+ return 1 ;
+}