Distributed Erlang, how do I generate unique node names?

228 Views Asked by At

I am building an Erlang server-client program. The server is written in Erlang OTP and the client in Java with Jinterface.

When creating a Jinterface connection I have to set a node name in the constructor OtpNode(). The problem is that this is done before connecting to the server (obviously), but each client must have unique names. If a client tries to connect to the server when a client with the same name is already connected, then the new connection fails.

How do I solve this? My first taught was to have a node without name or let the server supply the client with a name, but that does not seems to work...

1

There are 1 best solutions below

0
Nathaniel Waisbrot On

Sounds like a job for UUID.randomUUID().

"UUID" stands for "Universally Unique ID", and it allows you to assume that any two clients will generate a different UUID without needing to contact each other.