So, let's look at these functions in turn. The first thing we need to do is to establish a connection. We do this with the function ConnectAttach(), which looks like this:
#include <sys/neutrino.h> int ConnectAttach (int nd, pid_t pid, int chid, unsigned index, int flags);
ConnectAttach() is given three identifiers: the nd, which is the Node Descriptor, the pid, which is the process ID, and the chid, which is the channel ID. These three IDs, commonly referred to as ND/PID/CHID, uniquely identify the server that the client wants to connect to. We'll ignore the index and flags (just set them to 0).
So, let's assume that we want to connect to process ID 77, channel ID 1 on our node. Here's the code sample to do that:
int coid; coid = ConnectAttach (0, 77, 1, 0, 0);
As you can see, by specifying a nd of zero, we're telling the kernel that we wish to make a connection on our node.
At this point, I have a connection ID, a small integer that uniquely identifies a connection from my client to a specific channel on a particular server.
I can use this connection ID when sending to the server as many times as I like. When I'm done with it, I can destroy it via:
ConnectDetach (coid);
So let's see how I actually use it.