aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/platform.h38
-rw-r--r--src/core/transport.c2
2 files changed, 40 insertions, 0 deletions
diff --git a/src/core/platform.h b/src/core/platform.h
index 5a504dec..2955215b 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -64,6 +64,7 @@ typedef struct nni_plat_mtx nni_plat_mtx;
typedef struct nni_plat_cv nni_plat_cv;
typedef struct nni_plat_thr nni_plat_thr;
typedef struct nni_plat_tcpsock nni_plat_tcpsock;
+typedef struct nni_plat_ipcsock nni_plat_ipcsock;
// Mutex handling.
@@ -208,6 +209,43 @@ extern int nni_plat_tcp_send(nni_plat_tcpsock *, nni_iov *, int);
// full, or an error condition occurs.
extern int nni_plat_tcp_recv(nni_plat_tcpsock *, nni_iov *, int);
+// nni_plat_ipc_init initializes the socket, for example it can
+// set underlying file descriptors to -1, etc.
+extern void nni_plat_ipc_init(nni_plat_ipcsock *);
+
+// nni_plat_ipc_fini just closes an IPC socket, and releases any related
+// resources.
+extern void nni_plat_ipc_fini(nni_plat_ipcsock *);
+
+// nni_plat_ipc_shutdown performs a shutdown of the socket. For
+// BSD sockets, this closes both sides of the IPC connection gracefully,
+// but the underlying file descriptor is left open. (This part is critical
+// to prevention of close() related races.)
+extern void nni_plat_ipc_shutdown(nni_plat_ipcsock *);
+
+// nni_plat_tcp_listen creates an IPC socket in listening mode, bound
+// to the specified path. Note that nni_plat_ipcsock should be defined
+// to whatever your platform uses. For most systems its just "int".
+extern int nni_plat_ipc_listen(nni_plat_ipcsock *, const char *);
+
+// nni_plat_ipc_accept does the accept to accept an inbound connection.
+// The ipcsock used for the server will have been set up with the
+// nni_plat_ipc_listen.
+extern int nni_plat_ipc_accept(nni_plat_ipcsock *, nni_plat_ipcsock *);
+
+// nni_plat_ipc_connect is the client side.
+extern int nni_plat_ipc_connect(nni_plat_ipcsock *, const char *);
+
+// nni_plat_ipc_send sends data to the peer. The platform is responsible
+// for attempting to send all of the data. The iov count will never be
+// larger than 4. The platform may modify the iovs.
+extern int nni_plat_ipc_send(nni_plat_ipcsock *, nni_iov *, int);
+
+// nni_plat_ipc_recv recvs data into the buffers provided by the
+// iovs. The implementation does not return until the iovs are completely
+// full, or an error condition occurs.
+extern int nni_plat_ipc_recv(nni_plat_ipcsock *, nni_iov *, int);
+
// nni_plat_seed_prng seeds the PRNG subsystem. The specified number
// of bytes of entropy should be stashed. When possible, cryptographic
// quality entropy sources should be used. Note that today we prefer
diff --git a/src/core/transport.c b/src/core/transport.c
index cf9f38c3..25a881d6 100644
--- a/src/core/transport.c
+++ b/src/core/transport.c
@@ -15,10 +15,12 @@
// to the system dynamically is something that might be considered later.
extern nni_tran nni_inproc_tran;
extern nni_tran nni_tcp_tran;
+extern nni_tran nni_ipc_tran;
static nni_tran *transports[] = {
&nni_inproc_tran,
&nni_tcp_tran,
+ &nni_ipc_tran,
NULL
};