This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am not sure whether this is the right place to post this question or not.
I need to make a client-server application where the client will log in for some service. Whenever the client logs in the server will provide a unique number to the client, this number will help the server to identify a client. I was wondering what would be the best way to generate this unique number. Should I use IP address of the client to generate this number or not. Please do let me know about your ideas/suggestion and if possible any good literature that I can refer to.
Well depends on how you look at it. A computer indeed only has one IP address. But from the application viewpoint, if say you allow 2 different users to log in at the same time on the same computer ... voila IP generated session ID will crash.
A better approach may be to use the hashcode of the username and password.
You are right about two people with the same IP, K Tsang. Thank you. We also have people here on JavaRanch whose IP changes from time to time; presumably they log in on different computers.
A hash, however, risks collisions; it is only a matter of time before two people have the same hash.