You may edit your post, and insert them later, if you forgot them - i.e.: now.
--- To the content of your question: Normally, a service is running on a server, allowing multiple clients to connect to it. The port is a kind of adress, where the service is reachable.
The server is started (months) before the client requests it.
How can the client inform the server, that it likes to access the service on port xy? And why?
Do you want to start a server for every client? When the first client begs to use Port 7778, and the second client likes to have it waiting on 7776?
What if the client is asking for a port already in use - i.e.: port 80, 21, 7 or some other well known port?
You may start a server on port 7777, to wait for the information of client where to listen, and start a new Thread, listening on that port. But you only moved the fixed port to another level.
Think about the port-number like your telephone-number. People who want to call you need to know your number, and cannot specify the number, under which they want to reach you. You could give them a primary-request number, where they may call you, and tell you 'I want to reach you under 666-44-345', and you could then call your telephone-company, and ask them, to get a second telephone number '666-44-345', and if it is possible - the number isn't in use right now, wait on the call on your second phone. But why?
--- Additional hints: You needn't import java.lang.*;
And if you open a stream for reading (from System.in or whereether), you don't need a new Streamobject for every readLine()-call. Generate one object, and read from that:
[ October 24, 2004: Message edited by: Stefan Wagner ]