That is a unique feature of web page access and can’t be used with regular sockets. It can be used with servlets, though, because they are basically web pages.
Edit: Now that the question has been revised, I can now answer the underlying question much better than the original question. It is not a good idea to assign each user a port. Then you are limited to about 64000 users. Instead, the user should transmit authentication information with each request, or transmit it when opening the connection and then use only that connection.
1
solved Argument passing to Java Socket Program