Unique number generator?

Dave Jones djones at megatest.UUCP
Fri Sep 9 12:04:36 AEST 1988



What's the best way for a process to generate a network-wide
unique number which will remain unique over time?  (A very, very 
high probability of uniqueness may have to be good enough.)

Just off the top of my head, I think of this idea:  Add together
the number that you get from gettimeofday(), and the number you get
from getpid(), and a number you get by hashing the string obtained
from gethostname().  Maybe you want to multiply the getpid number by
100000 or so before you add it.

I thought of using the ethernet machine address, which admittedly
adds a little bit more non-portability, but I don't know exactly how
to look it up at runtime anyway.

Anybody got an idea on this?  Sun gurus: Can the yellow-pages daemon
or the portmapper be any help?



More information about the Comp.unix.wizards mailing list