Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: How do I know my Q-KEY is unique ? Keywords: msg queue, queue, message queue, ID Message-ID: <2492@auspex.auspex.com> Date: 24 Sep 89 00:12:15 GMT References: <1747@draken.nada.kth.se> <1196@virtech.UUCP> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 24 >There is no way to "register" or reserve an IPC key value. Most software >that I have seen using ipc's has used one of the following: > > [methods 1, 2, 3, and 4] 5. Pick some file as a "rendezvous" point, and use "ftok". To quote the SunOS 4.0 version of the "ftok" manual page: All interprocess communication facilities require the user to supply a key to be used by the msgget(2), semget(2), and shmget(2) system calls to obtain interprocess communication identifiers. One suggested method for forming a key is to use the ftok() subroutine described below. Another way to compose keys is to include the project ID in the most signi- ficant byte and to use the remaining portion as a sequence number. There are many other ways to form keys, but it is necessary for each system to define standards for forming them. If some standard is not adhered to, it will be possi- ble for unrelated processes to unintentionally interfere with each other's operation. Therefore, it is strongly sug- gested that the most significant byte of a key in some sense refer to a project so that keys do not conflict across a given system.