if you are in Linux 8080 / 80 / 8443 are no good ports us an other port like 3456. And always always Close your socket from your Client.
Update: first of all, you should not Close the Server socket with Server.close(), Server should be running. and thats why the while Loops is there. you should Close your Client socket, with socket.close() after you have get the inputstream from Server. Remember also to always Close your outputstream with Close() after your write() and flush() to avoid side effect. Make two class, one for the Server and one for the Client. Start Java class Server first, and then run your Client class to connect to Server. terminate your Client class and run it again. if you are using eclipse, also terminate the Client in your console. sometimes the Java processes are overlaping, so just terminate all the running process with the x button. After you have improved your example codes, you can start Server and Client class again. If it is still not working, you need to repost your question again and Show your current codes in Details for the Client and Server. somehow i have lost the track, where is your current state, cause you have already approved the answer to your question.