To obtain a unique ID, a key must be used. The key must be mutually agreed upon by both client and server processes. This represents the first step in constructing a client/server framework for an application.
When you use a telephone to call someone, you must know their number. In addition, the phone company must know how to relay your outgoing call to its final destination. Once the other party responds by answering the telephone call, the connection is made.
In the case of System V IPC facilities, the ``telephone'' correllates directly with the type of object being used. The ``phone company'', or routing method, can be directly associated with an IPC key.
The key can be the same value every time, by hardcoding a key value into an application. This has the disadvantage of the key possibly being in use already. Often, the ftok() function is used to generate key values for both the client and the server.
LIBRARY FUNCTION: ftok(); PROTOTYPE: key_t ftok ( char *pathname, char proj ); RETURNS: new IPC key value if successful -1 if unsuccessful, errno set to return of stat() call
key_t mykey; mykey = ftok("/tmp/myapp", 'a');
key_t mykey; mykey = ftok(".", 'a');
The key value, however it is obtained, is used in subsequent IPC system calls to create or gain access to IPC objects.