Hey guys im new to java but this morning i decided to look into the basics of java networking. i found this amazing tutorial online so i decided to edit it and see what i could do with it.

The tutorial provided a server and a client, the client connects to the server sends a message automatically then sends "bye" to close the connection. i have changed this where it lets me send a message but it only sends one message please take a look at the code below.

Java Code:
message = (String)in.readObject();
					
					System.out.println("server>" + message);
					
					System.out.print("Type Message: ");
					
					Scanner mainMessage = new Scanner(System.in);
										
					String tehMainMessage = mainMessage.next();
					
					sendMessage(tehMainMessage);
how could i loop this untill mainMessage = bye and then when it = bye it will drop out of the loop and carry on with the rest of the code.

Thanks very much and i know i may be into deep before i can swim but how else are ya gunna learn haha.

Thanks very much :)