Channel: Servers receive on channels.
Connection: Clients should connect/attach to the channel first, then send to the channel using the connection.
int ChannelCreate(unsigned flags)
_NTO_CHF_PRIVATE only be used inside a process
_NTO_CHF_FIXED_PRIORITY receiving threads won’t change priorities to those of the sending threads.
_NTO_CHF_THREAD_DEATH ask to deliver a pulse if a thread is dead.
_NTO_CHF_DISCONNECT Deliver a pulse when all connections from a process are detached.
_NTO_CHF_COID_DISCONNECT Deliver a pulse to all connections if the channel is destroyed.
Int coid = ConnectAttach(node_id, pid, chid, index | _NTO_SIDE_CHANNEL, flags)
_NTO_SIDE_CHANNEL should always be used, to make sure the returned coid is greater than any valid file descriptor.
When _NTO_SIDE_CHANNEL is used, index is ignored.
How does the client find the server?
Before MsgSend(coid, &msg, ..), a connection attach is required, coid = ConnectAttach(nd, pid, chid…).
- If they are in same process, it is easy. Sharing “chid” across the process should work.
- If they are not (common case), below is how…
If server is a Resource manager
- The server: resmgr_attach(..,”/dev/mymgr/”,…);
- The client: fd = open(“/net/nodenme/dev/mymgr”, ..);
- Write(fd,..), read(fd,..), MsgSend(fd,…)
- note: fds are a particular type of coid.
If server is just A simple MsgReceive() loop,
- server: name_attach(NULL, “myname”, 0);
- client: coid = name_open(“myname”, 0);
- MsgSend(coid, &msg,….);