You are closing the socket (obviously, judging by the error)
while (!done) {
String line = in.readLine();
String next = null;
String[] temp;
System.out.println(line);
if (line.trim().equals("login")) {
next = "login";
out.println("login");
}
if (line.trim().equals("BYE")) done = true;
if (next == "login") {
temp = line.trim().split(":");
out.println("Welcome " + temp[0]);
}
incoming.close();
}
incoming.close();? You are closing that at the end of the while loop? Should it not be called right AFTER the while loop is done executing? This way you are closing the stream after each time the loop executes, which is not whatyou want.