Establishing a connection
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 the sample shown here.
#include <sys/neutrino.h>
int ConnectAttach (int reserved,
pid_t pid,
int chid,
unsigned index,
int flags);
ConnectAttach() is given two identifiers: the pid, which is
the process ID, and the chid, which is the channel ID. These two IDs,
commonly referred to as 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).
int coid;
coid = ConnectAttach (0, 77, 1, 0, 0);
How did I figure out I wanted to talk to process ID 77 and channel ID 1? We'll see that shortly
(see Finding the server's PID/CHID,
below).
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.
ConnectDetach (coid);
So let's see how I actually use it.