Path: utzoo!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: How do I know my Q-KEY is unique ? Keywords: msg queue, queue, message queue, ID Message-ID: <1196@virtech.UUCP> Date: 23 Sep 89 20:57:11 GMT References: <1747@draken.nada.kth.se> Organization: Virtual Technologies Inc Lines: 26 In article <1747@draken.nada.kth.se>, d88-jwa@nada.kth.se (Jon W{tte) writes: > I am currently considering using message queues for a game I'm writing. > The problem is: when I create a message queue, I pass a (hopefully) > unique 32-bit key. How do I make SURE this key is unique ? (I need to > compile the key into a server as well as a client...) 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: 1. have the initial process obtain a "private" IPC and write the IPC id into a file that is read by all other programs using the IPC. Note that this is better than selecting an unused key because you don't have to hunt around. 2. Use a control file that has the specified key. 3. #2 but allow for an override by an environment variable. 4. hard code in a specific key and hope you don't collide. This is the worst solution. -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+